简体   繁体   中英

Perl DBI MySQL Updates

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?

# BIND TABLE COLUMNS TO VARIABLES
$sth->bind_columns(undef, \$id, \$product, \$quantity);

# LOOP THROUGH RESULTS
while($sth->fetch()) {
   print "$id, $product, $quantity <br />";
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM