note 111119 added to function.odbc-num-rows

From: Date: Thu, 17 Jan 2013 09:25:36 +0000
Subject: note 111119 added to function.odbc-num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-193123@lists.php.net to get a copy of this message
If you are using 'odbc_num_rows' function connecting to a MSSQL 2008 Server using the Microsoft PHP driver and querying a stored procedure having the SET NOCOUNT ON comand within the stored procedure code will always return "-1", as it seems that the odbc interface is relaying on the parameter reported by the "Number of rows affected" statement from the MSSQL server. This might also apply to other drivers or database systems. If SET NOCOUNT OFF is used or nothing stated (default setting on MSSQL) in the stored procedure code everything is working as intended. Example PHP code: <?php $query = 'execute sp_getInformation()'; $resID = odbc_exec($conn, $query); echo 'Number of rows: ' . odbc_num_rows($resID); ?> Example Stored Procedure code: CREATE PROCEDURE sp_getInformation AS SET NOCOUNT ON SELECT * from Table GO ---- Server IP: 69.147.83.199 Probable Submitter: 64.211.102.18 ---- Manual Page -- http://php.net/manual/en/function.odbc-num-rows.php Edit -- https://master.php.net/note/edit/111119 Del: integrated -- https://master.php.net/note/delete/111119/integrated Del: useless -- https://master.php.net/note/delete/111119/useless Del: bad code -- https://master.php.net/note/delete/111119/bad+code Del: spam -- https://master.php.net/note/delete/111119/spam Del: non-english -- https://master.php.net/note/delete/111119/non-english Del: in docs -- https://master.php.net/note/delete/111119/in+docs Del: other reasons-- https://master.php.net/note/delete/111119 Reject -- https://master.php.net/note/reject/111119 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193123) next »