ID:               35935
 Comment by:       keyvez at hotmail dot com
 Reported By:      victoria at balic dot net
 Status:           Assigned
 Bug Type:         PDO related
 Operating System: RHEL4-64/CentOS 4.2-64
 PHP Version:      5.1.1
 Assigned To:      wez
 New Comment:

I am experiencing the same issue on Windows and MSSQL.

Stored Procedure Create Code:
******************************************
CREATE PROCEDURE [dbo].[p_sel_all_termlength]
  @err INT = 0 OUTPUT AS
SELECT * FROM termlength
SET @err = 2627
******************************************

PHP Code:
******************************************
$Link = new PDO('mssql:host=sqlserver;dbname=database', 'username',
'password');
        
$ErrorCode = 0;
        
$Stmt = $Link->prepare('p_sel_all_termlength ?');
$Stmt->bindParam(1,$ErrorCode,PDO::PARAM_INT,4);
$Stmt->execute();
echo "Error = " . $ErrorCode . "\n";

while ($Row = $Stmt->fetch(PDO::FETCH_OBJ)) {
        echo $Row->description . "\n";
}

echo "Error = " . $ErrorCode . "\n";
******************************************

PHP Output:
******************************************
Error = 0
9 Weeks
Semester
One Year
Trimester
Error = 0
******************************************


Previous Comments:
------------------------------------------------------------------------

[2006-01-09 20:34:14] victoria at balic dot net

I just used the latest snapshot as instructed (5.1.2RC3-dev 20060109)
and I get the same behaviour as reported above -- ie. the PDO call
returns empty value when using bindParam().

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

[2006-01-09 10:19:30] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip



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

[2006-01-09 00:26:08] victoria at balic dot net

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 this bug report at http://bugs.php.net/?id=35935&edit=1

Reply via email to