Once You Know, You Newegg

mySQL How many rows?

Return the number of rows changed (updated, deleted, etc.) by the last command.

This is usually used after a non-SELECT execute statement.
$rowcount = $sth->rows;

$st->rows ##returns 1

This is handy for many reasons. I use it to bail out of a sub when no rows are returned and for loop security redundancy.
So I can do a :
until ($rows==0){
foreach (@somearray){
print $_.'<br />’;

Which in some cases, I am not actually using @somearray rows! I may just need to process @somearray up to a certain point.

Comments are closed.