在Cakephp中从MySQL调用存储过程只获得第一行结果

时间:2012-07-12 01:07:14

标签: php mysql sql cakephp

当我打电话给我的SP时,它只给我第一个结果,在第二个电话中,它给了我这个:

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.

好吧,我已经按照Stackoverflow的建议检查了相关问题。有些人给了我这个想法,但是当我尝试它时,它不起作用。

这是我的函数中调用我的SP的循环:

foreach ($filenames as $value)
    {
    $queryssid = "CALL GetUniqueSSIDByCategoryCombine('$username','$value');";
    $dataUniqueSSID = $this->User->query($queryssid);
    pr($dataUniqueSSID);
    }

这是我的SP:

CREATE DEFINER=`root`@`localhost` PROCEDURE `GetUniqueSSIDByCategoryCombine`(uid VARCHAR(50),filename VARCHAR(50))
 BEGIN
 SELECT  DISTINCT(transaction_details.essid) AS 'SSID', transaction_details.protocol AS 'protocol', TRANSACTION.filename
 FROM    transaction_details transaction_details, TRANSACTION TRANSACTION  
 WHERE transaction_details.uid_filename_link = TRANSACTION.uid_filename_link AND transaction_details.uid_filename_link = 
     (
         SELECT distinct(transaction.uid_filename_link) FROM TRANSACTION 
         WHERE transaction.uid = uid AND transaction.filename = filename
     ) 
 ORDER BY row_id;
     END

可能是什么解决方案。这是我处理这个错误的第二天,这有点令人沮丧。提前谢谢。

1 个答案:

答案 0 :(得分:0)

哦,这是我的PHP版本的罪魁祸首。从PHP 5.3.1开始,我升级到了最新版本。