PDO::rowCount() returning -1

前端 未结 2 1751
不思量自难忘°
不思量自难忘° 2021-01-15 03:25

i have this function below. that i used to run on a MySQL DB. I had to move to a SQL Server 2008, easy thing.

But, after that, the rowCount()

2条回答
  •  轮回少年
    2021-01-15 04:02

    I think you may be running into the gotcha on the PDO rowCount() function. As stated in the PHP manual. The second sentence is the gotcha...:

    "If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behavior is not guaranteed for all databases and should not be relied on for portable applications."

    Instead, you should use a COUNT(*) sql statement.

提交回复
热议问题