|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bcardoso at ccg dot pt
New email:
PHP Version: OS:


 [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: Thu May 19 19:04:05 2022 UTC