#19497 [Opn->Bgs]: odbc_num_rows gives -1 if I do not use ORDER BY
| From: | kalowsky@php.net | Date: | Thu, 19 Sep 2002 12:24:14 +0000 |
| Subject: | #19497 [Opn->Bgs]: odbc_num_rows gives -1 if I do not use ORDER BY | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-19745@lists.php.net to get a copy of this message | ||
ID: 19497
Updated by: kalowsky@php.net
Reported By: bcardoso@ccg.pt
-Status: Open
+Status: Bogus
Bug Type: ODBC related
Operating System: Windows .Net Standard Server RC1
PHP Version: 4.2.2
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2002-09-19 06:21:25] bcardoso@ccg.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)
...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19497&edit=1