且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 ODBC 连接在 PHP 中获取结果集中的计数或行数?

更新时间:2023-02-06 08:41:43

odbc_num_rows 似乎仅适用于 INSERT、UPDATE 和 DELETE 查询.

odbc_num_rows seems to be reliable for INSERT, UPDATE, and DELETE queries only.

手册说:

使用 odbc_num_rows() 来确定 SELECT 后可用的行数将返回 -1 与许多驱动程序.

Using odbc_num_rows() to determine the number of rows available after a SELECT will return -1 with many drivers.

解决此行为的一种方法是在 SQL 中执行 COUNT(*).请参阅此处以获取示例.

one way around this behaviour is to do a COUNT(*) in SQL instead. See here for an example.