php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-19 07:24 UTC] kalowsky@php.net
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 http://www.php.net/support.php

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 www.php.net).  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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC