How to determine fetchrow_arrayref is empty in MySQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poolboi
    New Member
    • Jan 2008
    • 170

    How to determine fetchrow_arrayref is empty in MySQL?

    hey guys,

    need help on this code:
    [CODE=perl]
    $sth = $dbh->prepare("SELEC T * FROM `mml log` WHERE Commands LIKE '%$IMSI%'");
    $sth->execute();


    my $numFields = $sth->{'NUM_OF_FIELD S'};
    while (my $ref = $sth->fetchrow_array ref){
    print "--------------------------------------------------------------------------------";

    for (my $i=0; $i<$numFields; $i++){
    printf ("%s %s", $i ? "," : "", $$ref[$i]);
    }
    print "--------------------------------------------------------------------------------";
    }
    [/CODE]

    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
  • poolboi
    New Member
    • Jan 2008
    • 170

    #2
    hm..guys
    anyone has any idea how i can determine if the above code of fetchrow_arrayr ef
    , how can i determine if it's empty or not?

    Comment

    Working...