CakePHP中的存储过程错误

时间:2012-08-02 08:33:44

标签: php mysql stored-procedures mysqli cakephp-2.1

知道如何在CakePHP中调用存储过程吗?

$results = $this->query('call p2');
echo $results;

我不断收到此错误:

Error: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered 
queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code 
is only ever going to run against mysql, you may enable query buffering by setting the 
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

2 个答案:

答案 0 :(得分:0)

我在事务中完成了这项工作,以确保在其间没有调用过程的其他实例:

$this->begin();
$this->query("CALL procedure();");
$result = $this->query("SELECT something");
$this->commit();

您的问题可能是您正在致电:

$this->query('call p2');

你应该打电话的地方:

$this->query('call p2()');

因为程序很像函数。

答案 1 :(得分:-2)

你应该打开和关闭括号

$results = $this->query('call p2()');
echo $results;
相关问题