note 79505 added to function.odbc-num-rows
| From: | areznik at survdata dot com | Date: | Fri, 30 Nov 2007 18:04:21 +0000 |
| Subject: | note 79505 added to function.odbc-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132697@lists.php.net to get a copy of this message | ||
I could have been noted before in this thread but I couldnt find it on my first search.
This function (odbc_num_rows) returns -1 when ODBCing to MS SQL and making it hard to get the number
of rows in the returned recordset.
Two workarounds:
1. When you just need to verify that any rows returned from your query you can use select
count(*) as cnt from table and then just get $row['cnt']
2. When you need to actually loop through the records this function returns number of rows in the
recordset if and only if you include ORDER BY clause in your query statement.
That sounds a bit annoying but thats the work around when dealing with MS SQL odbc driver I guess.
It would be beneficial if someone explained how the Order By clause makes the difference.
----
Server IP: 208.69.120.35
Probable Submitter: 207.106.35.30
----
Manual Page -- http://www.php.net/manual/en/function.odbc-num-rows.php
Edit -- https://master.php.net/note/edit/79505
Del: integrated -- https://master.php.net/note/delete/79505/integrated
Del: useless -- https://master.php.net/note/delete/79505/useless
Del: bad code -- https://master.php.net/note/delete/79505/bad+code
Del: spam -- https://master.php.net/note/delete/79505/spam
Del: non-english -- https://master.php.net/note/delete/79505/non-english
Del: in docs -- https://master.php.net/note/delete/79505/in+docs
Del: other reasons-- https://master.php.net/note/delete/79505
Reject -- https://master.php.net/note/reject/79505
Search -- https://master.php.net/manage/user-notes.php