|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19497 odbc_num_rows gives -1 if I do not use ORDER BY
Submitted: 2002-09-19 06:21 UTC Modified: 2002-09-19 07:24 UTC
From: bcardoso at ccg dot pt Assigned:
Status: Not a bug Package: ODBC related
PHP Version: 4.2.2 OS: Windows .Net Standard Server RC1
Private report: No CVE-ID: None
 [2002-09-19 06:21 UTC] bcardoso at ccg dot pt
When using the same code in 2 pages (only the query is different), I checked that odbc_num_rows gives -1 in one of them (the other is ok).

I check the SQL statement, and I conclude:
- if I use ORDER BY (SELECT .. FROM ... ORDER BY ...) the function odbc_num_rows gives me the right number;
- if I remove the ORDER BY (SELECT .. FROM ...), the odbc_num_rows gives -1

$sql=("SELECT id,term FROM dict WHERE state IN (0,1) ORDER BY term");
if (odbc_num_rows($result)==0)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-19 07:24 UTC]
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit

Thank you for your interest in PHP.

As per ODBC  spec, SQLNumRows is not required to return the number of rows returned by a SELECT statement, but rather to any INSERT or DELETE statement only (this is in the documentation on  A SELECT can return the number of result rows, but that is entirely upto the driver being used, and is not assured to work.  
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue May 17 15:03:34 2022 UTC