ID: 39707
Comment by: aballard at gmail dot com
Reported By: aspen dot olmsted at alliance dot biz
Status: Assigned
Bug Type: PDO related
Operating System: Windows XP SP2
PHP Version: 5.2.0
Assigned To: wez
New Comment:
I also appear to be unable to retrieve stored procedure return values.
SQL Procedure:
==================
CREATE PROCEDURE [dbo].[Write]
@id varchar(255),
@data varchar(4000)
AS
SET NOCOUNT ON
IF EXISTS(SELECT * FROM MyTable WHERE id = @id)
UPDATE MyTable SET
data = @data
WHERE id = @id
ELSE
INSERT INTO MyTable (id, data)
VALUES (@id, @data)
RETURN @@ROWCOUNT
GO
PHP:
===================
$stmt = $this->dbHandle->handle()->prepare("EXEC ? =
dbo.WebSession_Write ?, ?");
$stmt->bindParam(1, $return_value,
PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT);
$stmt->bindParam(2, $sessID, PDO::PARAM_STR);
$stmt->bindParam(3, $value, PDO::PARAM_STR);
$stmt->execute();
$stmt = null;
if ($return_value == 1) {
return true;
} else {
return false;
}
Previous Comments:
------------------------------------------------------------------------
[2007-08-02 12:28:55] aballard at gmail dot com
I believe Bug #42076 is the same as this. I found it first and tacked
my comments there, but as this bug report is earlier and already
assigned, I guess I should be following this one.
------------------------------------------------------------------------
[2007-07-23 06:52:00] ydiazc at gmail dot com
On the stores procedures not returned parameter of output or input
output with php pdo and driver ODBC in both cases (sql server and
oracle).
PDO('odbc:Driver={Microsoft ODBC for Oracle}...
PDO('odbc:Driver={SQL Native Client}...
vote on the bug, is idem for both databases
the parameters of input or input output, They enter without problems to
store procedure, But they do not go out with value of procedure.
help me !!!, I need to use multiple engines.
Thank you for his help
------------------------------------------------------------------------
[2006-12-01 18:50:41] aspen dot olmsted at alliance dot biz
The line that says:
$sth = $dbh->prepare("EXECUTE spReturn_Int ?");
should be:
$sth = $dbh->prepare("EXECUTE spReturn_Int ?,?");
Sorry when I simplified the example I made this mistake
------------------------------------------------------------------------
[2006-12-01 18:00:40] aspen dot olmsted at alliance dot biz
Description:
------------
I am trying to pass output parameters to MSSQL through PDO using the
odbc driver.
If there is just one parameter it works. If there is more than one it
will not.
There is a sample to send an inout parameter to SQL on the pdo
documentation page I used as a starting place
Reproduce code:
---------------
SQL:
ALTER PROCEDURE spReturn_Int @err int OUTPUT, @err2 varchar(255)
AS
SET @err = 11
$sth = $dbh->prepare("EXECUTE spReturn_Int ?");
$invalue = 'Dog';
$sth->bindParam(1, $return_value,
PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT);
$sth->bindParam(2, $invalue, PDO::PARAM_STR);
$sth->execute();
print "procedure returned $return_value\n";
Expected result:
----------------
It should print "procedure returned 11"
Actual result:
--------------
It prints "procedure returned
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39707&edit=1