note 100883 added to function.odbc-num-rows
| From: | VadimIstratov at osu1 dot php dot net | Date: | Fri, 12 Nov 2010 16:35:03 +0000 |
| Subject: | note 100883 added to function.odbc-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173981@lists.php.net to get a copy of this message | ||
There is a much better way to count rows in SELECT queries for MSSQL. Just use T-SQL.
Thus the function would be:
<?php
function odbc_mssql_num_rows($dbh) {
$res = odbc_exec($dbh, 'SELECT @@ROWCOUNT AS cnt');
if ( @odbc_fetch_into($res, $row)) {
$count = trim( $row[0] );
} else {
$count = 0;
}
odbc_free_result($res);
return $count;
}
?>
Where $dbh is your database connection resource (see odbc_connect()). And make sure that your SELECT
statement is a last query before your odbc_mssql_num_rows() call.
----
Server IP: 69.147.83.197
Probable Submitter: 195.128.95.36
----
Manual Page -- http://www.php.net/manual/en/function.odbc-num-rows.php
Edit -- https://master.php.net/note/edit/100883
Del: integrated -- https://master.php.net/note/delete/100883/integrated
Del: useless -- https://master.php.net/note/delete/100883/useless
Del: bad code -- https://master.php.net/note/delete/100883/bad+code
Del: spam -- https://master.php.net/note/delete/100883/spam
Del: non-english -- https://master.php.net/note/delete/100883/non-english
Del: in docs -- https://master.php.net/note/delete/100883/in+docs
Del: other reasons-- https://master.php.net/note/delete/100883
Reject -- https://master.php.net/note/reject/100883
Search -- https://master.php.net/manage/user-notes.php