|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Submitted: 2008-01-18 08:32 UTC Modified: 2009-05-03 01:00 UTC
Avg. Score:4.8 ± 0.6
Reproduced:21 of 21 (100.0%)
Same Version:4 (19.0%)
Same OS:10 (47.6%)
From: coldgrass at gmail dot com Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.6 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-01-18 08:32 UTC] coldgrass at gmail dot com
environment:php5.2.5,mssql server 2005 
I can't retrieve stored procedure return values

Reproduce code:
$sth = $DB->prepare('exec proc_getDeviceNumByHdType :inpara,:usetable,:num');
$sth->bindParam(":inpara", $para, PDO::PARAM_STR);
$sth->bindParam(":usetable", $paraTable, PDO::PARAM_STR);
$sth->bindParam(":num", $return, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,1);

	create procedure [dbo].[proc_getDeviceNumByHdType] 
		@hdtype as varchar(256),
		@usetable varchar(50),
		@num int output 
		DECLARE @sql Nvarchar(1000)

		SET  @sql = N'SELECT @num=COUNT(*) from  '+CAST(@usetable AS NVARCHAR(50)) 
		EXECUTE sp_executesql @sql,N'@num int output',@num output

Expected result:
after call procedure ,there is no return value;

Actual result:
should have a value;


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-30 08:56 UTC] miha dot vrhovnik at domenca dot si
Can confirm this on Linux.

PHP 5.2.6, connecting to MSSQL 2000 via freetds 0.82RC4

Guys please fix that I had to revert back to mssql_* functions for calling stored procedures. So Now half of project uses PDO the other half the old functional style...
 [2008-11-26 22:37 UTC] aventurella at gmail dot com
I can confrim this on MySQL and PostgreSQL as well.  No PARAM_INPUT_OUTPUT values get bound through PDO when running a stored 
 [2008-11-26 22:39 UTC] aventurella at gmail dot com
forgot my php/OS version: 5.2.6 on OS X 10.5.5
 [2009-04-25 14:54 UTC]
Please try using this CVS snapshot:
For Windows:

 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-12-22 21:53 UTC] david dot wright at opticsplanet dot com
This is happening for me in 5.3.1., using Pdo_Dblib.  Trying to call a stored procedure on SQL Server 2005 server.  Cannot retrieve a value.

PHP version 5.3.1
Using Pdo_Dblib
Linux:  2.6.24-24-server SMP x86_64 GNU/Linux

PHP Code:
/** SNIP. Set up a valid $db here! **/

$return_value = 999;

$sth = $db->prepare("EXEC dbo.opsp_Test ?");
$sth->bindParam(1, $return_value, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT, 4);

echo "$return_value\n";

Return value ALWAYS comes back as 999, no matter what variations I try in bindParam call.

Here's my Stored Procedure:
	@TheOutputValue int OUTPUT
	SET @TheOutputValue = 11
 [2011-07-30 11:24 UTC] eugene dot trotsan at gmail dot com
I can confirm that the same issue is present in version 5.3.3. 

The value of $result in the following code snippet will not be changed after the SP is run (even though the procedure returns a value when run from SQL Server Management Studio / freetds / or via mssql_query()

$result = "";
$stmt = $pdo->prepare("exec sp_nextSerialNumGet ?")
$stmt->bindParam(8, $result, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 25);
echo $result; // empty 


$execArray = array(':result' => "");
$stmt = $pdo->prepare("call sp_nextSerialNumGet (:result)");
echo $stmt->fetch(); //empty, var_dump($stmt->fetchAll()) show array (0) {}
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 17 12:05:44 2022 UTC