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