Bug #50555 [Com]: PDO_DBLIB: Cannot retrieve output parameter from stored procedure

From: Date: Tue, 20 Nov 2018 13:41:20 +0000
Subject: Bug #50555 [Com]: PDO_DBLIB: Cannot retrieve output parameter from stored procedure
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218061@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50555&edit=1

 ID:                 50555
 Comment by:         jeremy dot hise at gmail dot com
 Reported by:        david dot wright at opticsplanet dot com
 Summary:            PDO_DBLIB: Cannot retrieve output parameter from
                     stored procedure
 Status:             Open
 Type:               Bug
 Package:            PDO DBlib
 Operating System:   2.6.24-24-server
 PHP Version:        5.3.1
 Block user comment: N
 Private report:     N

 New Comment:

Ubuntu, PHP 7, mySQL, still a problem. I'm sure other stacks (.NET/SQL Server/Java/Oracle)
don't have this problem. This is now been around for almost 10 years? 

Please please, fix this.


Previous Comments:
------------------------------------------------------------------------
[2017-10-06 07:34:26] php dot net at itsacon dot net

That might work, but only if you're willing to rewrite an entire application with an ugly hack
in order to upgrade to PHP 7.x

I really hope this gets fixed before 5.6 End-Of-Life.

------------------------------------------------------------------------
[2017-09-07 21:50:40] adambaratz@php.net

You should be able to write a query where you:
 - DECLARE a var
 - run the sproc, using the var as the output parameter
 - SELECT the var

Not as elegant as being able to use bindParam, but it's a workaround.

------------------------------------------------------------------------
[2017-09-06 08:31:35] php dot net at itsacon dot net

This bug still persists in PHP 7.1.9

And since PHP 7.x has dropped support for the old mssql extension, this is now a very important bug,
since it means there is no way to connect a Linux/BSD server to a Microsoft SQL server and have full
stored procedure functionality.

I have tried both PDO_ODBC and PDO_DBLIB, different versions of FreeTDS (both with iODBC and
UnixODBC backends), and I've found nothing that works for stored procedures with OUTPUT
parameters.

------------------------------------------------------------------------
[2016-09-12 22:01:23] adambaratz@php.net

Alternate test case in #70274.

------------------------------------------------------------------------
[2016-02-16 11:12:36] craig_carnell at hotmail dot com

I am experiencing the same issue with PHP 7.0.3, pdo_dblib and MSSQL 2008. Unfortunately I am having
to resort to pdo_dblib due to the removal of mssql* functions.

Here is my code:

$db = new PDO('dblib:host=myhost:1433;dbname=mydb', 'username',
'password');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "EXEC Stock_Level @myId=:myId, @StockLevel=:StockLevel";
$stmt = $db->prepare($sql);
$var = '12345';
$var2 = null;
$stmt->bindParam(":myId", $var, PDO::PARAM_STR);
$stmt->bindParam(":StockLevel", $var2, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT);

if(!$stmt->execute()) {
    echo "\nPDO::errorCode(): ", $stmt->errorCode();
}

echo "var 2 = " . $var2 . PHP_EOL;

This is a big problem!

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=50555


--
Edit this bug report at https://bugs.php.net/bug.php?id=50555&edit=1


Thread (15 messages)

« previous php.bugs (#218061) next »