By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,693 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,693 IT Pros & Developers. It's quick & easy.

How to determine fetchrow_arrayref is empty in MySQL?

100+
P: 170
hey guys,

need help on this code:
Expand|Select|Wrap|Line Numbers
  1. $sth = $dbh->prepare("SELECT * FROM `mml log` WHERE Commands LIKE '%$IMSI%'");
  2. $sth->execute();
  3.  
  4.  
  5. my $numFields = $sth->{'NUM_OF_FIELDS'};
  6. while (my $ref = $sth->fetchrow_arrayref){
  7.     print "--------------------------------------------------------------------------------";
  8.  
  9.     for (my $i=0; $i<$numFields; $i++){
  10.            printf ("%s  %s", $i ? "," : "", $$ref[$i]);
  11. }
  12.     print "--------------------------------------------------------------------------------";
  13.  
this is a code to fetch a row from MySQL
just would like to know...what those $i, ?, "," : "" within the bracket means?

also this will print if my database finds a record
if say it can't find a record, i want to print "Records not found"
but now do i determine if the row is empty, contains nothing
May 20 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 170
hm..guys
anyone has any idea how i can determine if the above code of fetchrow_arrayref
, how can i determine if it's empty or not?
May 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.