gpt4 book ai didi

perl - 使用DBI的非选择语句的prepare/execute时,如何获取受影响的行数?

转载 作者:行者123 更新时间:2023-12-04 16:55:30 25 4
gpt4 key购买 nike

根据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.

关于perl - 使用DBI的非选择语句的prepare/execute时,如何获取受影响的行数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6923230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com