Home > Backend Development > PHP Tutorial > php通过pdo调用存储过程,如何使用output返回值

php通过pdo调用存储过程,如何使用output返回值

WBOY
Release: 2016-06-23 14:23:41
Original
1389 people have browsed it

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)
Copy after login


回复讨论(解决方案)

$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(@?)");
试试

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template