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.
4

2 回答 2

0

我已在事务中完成此操作,以确保在其间不会调用该过程的其他实例:

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

您的问题可能是您正在调用:

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

你应该在哪里打电话:

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

因为过程很像函数。

于 2012-08-03T08:26:31.313 回答
-2

你应该打开和关闭括号

$results = $this->query('call p2()');
echo $results;
于 2013-10-07T15:16:01.620 回答