in reply to MySQL count with DBI
Smitz#!perl -w use strict; use DBI; my $dbh = DBI->connect('DBI:mysql:my_database', 'my_username', 'my_pas +sword') or die "Couldn't open database: $DBI::errstr; stopped"; # Prepare the SQL query for execution my $sth = $dbh->prepare(<<SQL) or die "Couldn't prepare statement: $DB +I::errstr; stopped"; SELECT COUNT(*) FROM music SQL # Execute the query $sth->execute() or die "Couldn't execute statement: $DBI::errstr; stop +ped"; #print result my ($count) = $sth->fetchrow_array(); print "Found $count results\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: MySQL count with DBI
by Itatsumaki (Friar) on May 09, 2003 at 15:11 UTC | |
by smitz (Chaplain) on May 09, 2003 at 15:33 UTC | |
by Itatsumaki (Friar) on May 09, 2003 at 16:45 UTC |