|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-01 18:00 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 04:00:01 2025 UTC |
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 mistakeOn 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 helpI 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; }