我不确定如何使用doctrine从symfony中的存储过程中正确检索OUT参数。
我的存储过程如下:
PROCEDURE procedure_name (IN val1 NUMERIC(10), ... , OUT out1 NUMERIC(10), OUT out2 NUMERIC(10), OUT out3 NUMERIC(10))
我试过了:
$sql = "CALL procedure_name('$val1', ... , @out1, @out2, @out3)";
$con = Doctrine_Manager::connection();
$statement = $con->prepare($sql);
$statement->execute();
$result = $con->query("SELECT @out1, @out2, @out3")->fetch_object();
但是因错误而失败"您必须至少在from中指定一个组件。"
有什么想法吗?
答案 0 :(得分:0)
解决方案:
$sql = "CALL procedure_name('$val1', ... , @out1, @out2, @out3)";
$con = Doctrine_Manager::getInstance()->getCurrentConnection();
$statement = $con->prepare($sql);
$statement->execute();
$statement->closeCursor();
$result = $con->fetchAssoc("SELECT @out1, @out2, @out3");