How to Get The Count or The Number Of Rows In A Result Set In PHP using ODBC Connection?

前端 未结 3 351
青春惊慌失措
青春惊慌失措 2021-01-14 01:53

While I build a web page in My PHP web application, My Connection works ok but When I want to get the count of rows of the SELECT Statement I used in my query, It gives me -

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 02:51

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

    The manual says:

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

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

提交回复
热议问题