微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

perl – 当我使用DBI为非select语句准备/执行时,如何获取受影响的行数?

根据 DBI文档,似乎我只能通过do方法获取受影响的行数.

$rows_affected = $dbh->do("UPDATE your_table SET foo = foo + 1");

如果使用prepare / execute,如何获得相同的结果?

解决方法

从有关 execute method in DBI的文档:

For a non-“SELECT” statement,“execute” returns the number of rows affected,if kNown. If no rows were affected,then “execute” returns “0E0”,which Perl will treat as 0 but will regard as true. Note that it is not an error for no rows to be affected by a statement. If the number of rows affected is not kNown,then “execute” returns -1.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐