Php_pdo call stored procedure, return parameter problem
$stmt = $db->prepare ("Call Pro_test (?, @?)");
$stmt->bindparam (1, $name);
$stmt->bindparam (2, $return _value, PDO::P aram_str, 4000);
Insert a row
$name = ' Chengdu city ';
$stmt->execute ();
Print_r ($return _value);
Call the stored procedure, return the parameter is empty, do you have, view the database, has successfully added data,
Execute directly in the database
SET @n =-1;
Call Pro_test ("Ah is intended", @n);
Select @n;
All returned are the correct parameters.
Share to: more
------Solution--------------------
Database may return multiple result sets when calling a stored procedure
In order: The result of the basic Select, the result of stored procedure 1, the result of stored procedure 2 ....
Your SQL command This is call Pro_test (?, @?) No select so can only be in the second result set
If writing select Call Pro_test (?, @?) is located in the first result set
Of course, the environment of ten changeable, you do not really know exactly where the results of the rally
So we need to loop the reading
do {
$rows = $stmt->fetchall (pdo::fetch_num);
if ($rows) {
Print_r ($rows);
}
} while ($stmt->nextrowset ());