Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Select COUNT in MySQL

by tchatzi (Acolyte)
on Jun 09, 2005 at 10:24 UTC ( #465047=note: print w/replies, xml ) Need Help??


in reply to Select COUNT in MySQL

First of all you Have to use prepare and execute with select.
Only with select though, it makes the execution of the whole thing faster.
With everything else use 'do'

and second to do what you want, do it like this (the right way....)
my $dbh = DBI->connect('DBI:mysql:foo','foo','foo') or die "Connect Error: $DBI::errstr"; my $count_sth = $dbh->prepare("SELECT COUNT(*) FROM company_info;") or die "Prepare Count Error: $DBI::errstr\n"; $count_sth->execute() or die "Execute Count Error: $DBI::errstr\n"; print $count_sth->fetchrow; $count_sth->finish; $dbh->disconnect;

Isn't it simple ?

``The wise man doesn't give the right answers, he poses the right questions.'' TIMTOWTDI

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465047]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2023-12-06 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (31 votes). Check out past polls.

    Notices?