|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70274 PDO Bind Param for INPUT_OUTPUT does not work
Submitted: 2015-08-14 22:11 UTC Modified: 2016-09-12 22:01 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: abarker at dandb dot com Assigned:
Status: Duplicate Package: PDO DBlib
PHP Version: 5.4.44 OS: OS X / Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: abarker at dandb dot com
New email:
PHP Version: OS:


 [2015-08-14 22:11 UTC] abarker at dandb dot com
I have been trying to get the last example at to work for the last two days.  The bindParam INPUT_OUTPUT variable never gets assigned when using the stored procedure.  I have verified that the stored procedure does indeed work when queried, PDO just fails to assign the variable.  Note this is an MsSQL server using dblib.

Test script:
   $database = "AdventureWorks";
   $server = "(local)";
   $dbh = new PDO( "sqlsrv:server=$server ; Database = $database", "", "");

   $dbh->query("IF OBJECT_ID('dbo.sp_ReverseString', 'P') IS NOT NULL DROP PROCEDURE dbo.sp_ReverseString");
   $dbh->query("CREATE PROCEDURE dbo.sp_ReverseString @String as VARCHAR(2048) OUTPUT as SELECT @String = REVERSE(@String)");
   $stmt = $dbh->prepare("EXEC dbo.sp_ReverseString ?");
   $string = "123456789";
   $stmt->bindParam(1, $string, PDO::PARAM_STR | PDO::PARAM_INPUT_OUTPUT, 2048);
   print $string;   // Expect 987654321 but received 123456789

Expected result:
$string === "987654321"

Actual result:
$string === "123456789"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-14 22:16 UTC] abarker at dandb dot com
Connection string in the example is different.  I am using: $dsn = 'dblib:host=;dbname=test_db';
 [2016-09-12 22:01 UTC]
-Status: Open +Status: Duplicate
 [2016-09-12 22:01 UTC]
See #50555.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 09:03:14 2021 UTC