467,146 Members | 1,013 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

How to determine fetchrow_arrayref is empty in MySQL?

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();
  5. my $numFields = $sth->{'NUM_OF_FIELDS'};
  6. while (my $ref = $sth->fetchrow_arrayref){
  7.     print "--------------------------------------------------------------------------------";
  9.     for (my $i=0; $i<$numFields; $i++){
  10.            printf ("%s  %s", $i ? "," : "", $$ref[$i]);
  11. }
  12.     print "--------------------------------------------------------------------------------";
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
  • viewed: 1743
1 Reply
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.

Similar topics

2 posts views Thread by atse | last post: by
reply views Thread by Thomas Svenson | last post: by
reply views Thread by Stuart Shay | last post: by
9 posts views Thread by paktsardines@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.