From:             victoria at balic dot net
Operating system: RHEL4-64/CentOS 4.2-64
PHP version:      5.1.1
PHP Bug Type:     PDO related
Bug description:  MySQL stored procedure doesn't return value when using 
bindParam()

Description:
------------
I created a trivial stored procedure in MySQL (v5.0.17) that simply
returns an integer constant. If I call the procedure using a PDO statement
and binding a return value $stmt->bindParam(), I get nothing. 
On the other hand, if I issue two SQL queries to implicitly obtain the
result, things are ok (see below). So something is broken with the way PDO
handles bindParam.

I am using the latest stable release of PHP (5.1.1), MySQL 5.0.17 and
mod_php for Apache 2.2

Reproduce code:
---------------
<?php
$DB = new PDO(...);
if($DB != NULL) {
 $stmt = $DB->prepare(" CALL test_pdo(?)");
 $stmt->bindParam(1, $return_value, PDO::PARAM_INT, 10); 
 $stmt->execute();
 print "Procedure returned: $return_value \n";

 //try instead plain SQL call
 $DB->query("CALL test_pdo(@nn)");
 $rows = $DB->query("SELECT @nn")->fetchAll();
 print "SELECT returned: \n";
 print_r($rows);
}
?>
And here's actual MySQL Stored procedure:
CREATE PROCEDURE test_pdo 
 (OUT Pout INTEGER)
BEGIN
  SET Pout := 1912;
END

Expected result:
----------------
$return_value should have been set to "1912" and instead it's empty. The
stored procedure is working ok as the second call (in which i implicitly
obtain the output by making two SQL queries) returns the correct value
(see below).

Actual result:
--------------
Procedure returned:

SELECT returned: 
Array ( [0] => Array ( [EMAIL PROTECTED] => 1912 [0] => 1912 ) )

-- 
Edit bug report at http://bugs.php.net/?id=35935&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35935&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35935&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35935&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35935&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35935&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35935&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35935&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35935&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35935&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35935&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35935&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35935&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35935&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35935&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35935&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35935&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35935&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35935&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35935&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35935&r=mysqlcfg

Reply via email to