ROW_COUNT 在 INSERT 或 UPDATE 后返回 0 [英] ROW_COUNT returns 0 after INSERT or UPDATE
问题描述
我有一个使用 Pear DB 处理 MySQL 数据库的 PHP 项目.该项目中的一个函数依赖于 SELECT ROW_COUNT()
的结果来找出受某些 SQL 语句影响的行数.在 MySQL 5.1 ROW_COUNT()
上的行为符合预期,而在 5.5 上它总是返回 0.
I have a PHP project that uses Pear DB to deal with MySQL database. One of the functions inside of that project relies on a result of SELECT ROW_COUNT()
to find out number of rows affected by certain SQL statement. On MySQL 5.1 ROW_COUNT()
behaves as expected, whilst on 5.5 it always returns 0.
我也尝试过通过 MySQL Workbench 执行插入并执行 SELECT ROW_COUNT()
并且它也返回 0.尽管通过 MySQL cli 做同样的事情,效果很好!
I have also tried performing an insert through MySQL Workbench and executing SELECT ROW_COUNT()
and it also returns 0. Although, doing same thing through MySQL cli, works fine!
有人偶然发现了吗?
谢谢!
推荐答案
row_count()
的行为在 MySQL 5.5 中发生了变化.有关更多信息,请参阅 MySQL RefMan for row_count().
The behaviour of row_count()
has changed in MySQL 5.5. For more Information see the MySQL RefMan for row_count().
这篇关于ROW_COUNT 在 INSERT 或 UPDATE 后返回 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!