
1arryb
User
Feb 26, 2009, 10:58 AM
Post #2 of 2
(4503 views)
|
Re: [seanliam] SELECT returning empty rows
[In reply to]
|
Can't Post
|
|
Hi Sean, If you are expecting $sth->rows to return the data, you will wait a long time . The rows method just returns the number of rows affected by the statement. I'm not sure if it actually returns anything useful for selects. To get the data, you need something like:
... $sth->execute; while ( my $row = $sth->fetchrow_hashref() ) { # Do something with the row. } ... UPDATE: Looking at the DBI perldoc, if you want $sth->rows to return the number of rows returned by your query, you have to get them all at the same time with $sth->fetchall_hashref() or $sth->fetchall_arrayref(). UPDATE 2: Of course, once you do that, you could just count the entries in the result structure directly. Cheers, Larry
(This post was edited by 1arryb on Feb 26, 2009, 11:13 AM)
|