2012-08-02 25 views
1

任何想法如何在CakePHP中調用存儲過程?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. 

回答

0

我做這個交易中,以確保該程序沒有其他實例稱爲其間:

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

你問題可能在於你打電話:

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

在哪裏,你應該叫:

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

的過程很像功能。

-2

您應打開和關閉括號

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

答案應該是詳細說明。 – techuser 2013-10-07 15:35:29