简体   繁体   English

Perl DBI MySQL更新

[英]Perl DBI MySQL Updates

I am wondering how you can print the results from the following Perl code snippet: 我想知道如何打印以下Perl代码片段的结果:

    $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? 如果您输入“SELECT * FROM table_name; into mySQL并显示整个关系,我想看看你会看到什么。是否有来自$ sth的返回值可以循环打印出来?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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