Reputation: 919
I am wondering how you can print the results from the following Perl code snippet:
$sth = $dbh->prepare("SELECT * FROM table_name");
$sth->execute();
I'd like to see what you would see if you typed "SELECT * FROM table_name; into mySQL and had the entire relation show up. Is there a return value from $sth that can be looped over and printed out?
Upvotes: 0
Views: 111
Reputation: 69
# BIND TABLE COLUMNS TO VARIABLES
$sth->bind_columns(undef, \$id, \$product, \$quantity);
# LOOP THROUGH RESULTS
while($sth->fetch()) {
print "$id, $product, $quantity <br />";
}
Upvotes: 2