Home >Backend Development >PHP Tutorial >php通过pdo调用存储过程,如何使用output返回值
CREATE PROCEDURE `para_out`(out id int)BEGIN SELECT 5 into id; SELECT id;END$stmt = $dbh->prepare("CALL para_out(?)");$stmt->bindParam(1, $return_value, PDO::PARAM_INT, 8);// call the stored procedureif($stmt->execute()==false) print_r($stmt->errorInfo());else print "procedure returned $return_value\n";//返回Array( [0] => 42000 [1] => 1414 [2] => OUT or INOUT argument 1 for routine test.para_out is not a variable or NEW pseudo-variable in BEFORE trigger)
$stmt->bindParam(1, $return_value, PDO::PARAMINT | PDO::PARAM_INPUT_OUTPUT, 8);
$stmt->bindParam(1, $return_value, PDO::PARAMINT | PDO::PARAM_INPUT_OUTPUT, 8);
一样的错误,
您的存储过程没有声明传入参数,怎么能 CALL para_out(?) 呢?
您的存储过程没有声明传入参数,怎么能 CALL para_out(?) 呢?
请教,那应该怎么写,让它返回5 , 谢谢,
每天回帖即可获得10分可用分
唉,没人回答~~~~
人呢,
坐等答案
$stmt = $dbh->prepare("CALL para_out(?)");
改成
$stmt = $dbh->prepare("CALL para_out(@?)");
试试