php.net |  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
Votes:1
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: abarker at dandb dot com
New email:
PHP Version: OS:

 

 [2015-08-14 22:11 UTC] abarker at dandb dot com
Description:
------------
I have been trying to get the last example at https://msdn.microsoft.com/en-us/library/ff628166(v=sql.105).aspx 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:
---------------
<?php
   $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);
   $stmt->execute();
   print $string;   // Expect 987654321 but received 123456789

Expected result:
----------------
$string === "987654321"

Actual result:
--------------
$string === "123456789"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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=000.000.000.000:65535;dbname=test_db';
 [2016-09-12 22:01 UTC] adambaratz@php.net
-Status: Open +Status: Duplicate
 [2016-09-12 22:01 UTC] adambaratz@php.net
See #50555.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 15:01:28 2024 UTC