Answer the question
In order to leave comments, you need to log in
How to get value of input/output parameter via pdo dblib?
MSSQL base.
php code:
$pdo = new \PDO("dblib:host= ;dbname= ;charset=utf8", $login, $password );
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$id = 0;
$name = 'текст';
$stm = $pdo->prepare(" EXEC [dbo].[SAVE] :id, :name ");
$stm->bindParam(":id", $id,\PDO::PARAM_INT|\PDO::PARAM_INPUT_OUTPUT , 4);
$stm->bindParam(":name", $name, \PDO::PARAM_STR, 255);
var_dump($stm->execute()); //true
var_dump($stm2->fetchAll(\PDO::FETCH_OBJ));
Answer the question
In order to leave comments, you need to log in
In a stored procedure, first specify SET NOCOUNT ON
.
If it doesn't work, return your parameters viaSELECT
Unfortunately, there is no right to change the procedureThen pass to someone with rights: INPUT_OUTPUT does not work .
CREATE PROCEDURE SaveTania @ID INT, @NAME VARCHAR(255)
AS BEGIN
SET NOCOUNT ON
EXECUTE [dbo].[SAVE] @ID, @NAME
SELECT @ID, @NAME
END
Well, its input is 0.
And so you get to the elementary one - PDO::lastInsertId
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question