如何使用 Doctrine return 从 Symfony 1.4 中的存储过程输出参数
How to return OUT parameters from stored procedure in Symfony 1.4 using Doctrine
我不确定如何使用 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();
但是失败并出现错误 "You must have at least one component specified in your from."
有什么想法吗?
解决方案:
$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");
我不确定如何使用 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();
但是失败并出现错误 "You must have at least one component specified in your from."
有什么想法吗?
解决方案:
$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");