php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46657 MySQL PDO bindParam on Stored Procedure with INOUT fails to bind returned value
Submitted: 2008-11-24 04:28 UTC Modified: 2009-05-03 01:00 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:1 (16.7%)
From: aventurella at gmail dot com Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.6 OS: OS X 10.5.5
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: aventurella at gmail dot com
New email:
PHP Version: OS:

 

 [2008-11-24 04:28 UTC] aventurella at gmail dot com
Description:
------------
Using the example in the PHP docs for binding an INOUT in a stored 
procedure, the process appears to fail

http://us3.php.net/manual/en/pdo.prepared-statements.php

see example 5

The principle difference between this and Bug #35935 is that 

$stmt->bindParam(1, $value, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 10); 

In the code was not presented, which should address the issue.

Reproduce code:
---------------
MySQL 5.0.67
EITHER OF THE FOLLOWING:
1)
CREATE PROCEDURE `tablename`.`sp_takes_string_returns_string`(INOUT str VARCHAR(10))
BEGIN
SELECT 'world' INTO str;
END;

2)
CREATE PROCEDURE `tablename`.`sp_takes_string_returns_string`(INOUT str VARCHAR(10))
BEGIN
SET str = 'world'
END;


PHP:
$dbh = new PDO($server.':host='.$host.';dbname='.$catalog, $username, $password, array(PDO::ATTR_PERSISTENT => true));
$stmt = $dbh->prepare("CALL sp_takes_string_returns_string(?)");
$value = 'hello';
$stmt->bindParam(1, $value, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 10); 

// call the stored procedure
$stmt->execute();

print "procedure returned $value\n";


Expected result:
----------------
procedure returned world

Actual result:
--------------
procedure returned hello

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-26 22:33 UTC] aventurella at gmail dot com
This also happens with PostgreSQL and MSSQL
http://bugs.php.net/bug.php?id=43887
 [2008-11-27 00:38 UTC] aventurella at gmail dot com
I guess this is the root of the problem for MySQL:
http://www.artfulsoftware.com/infotree/tip.php?id=130
 [2009-04-25 15:21 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [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".
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Oct 07 03:05:56 2022 UTC