Php 使用pdo获取mysql过程时出错

Php 使用pdo获取mysql过程时出错,php,mysql,pdo,Php,Mysql,Pdo,我正在尝试使用pdo从mysql过程中获取多个结果, 我可以从#1得到结果,但#2永远不会向浏览器返回值。这里发生了什么 顺便说一下,onequery实际上是这样的: public function onequery($query) { $this -> statement = $this ->dbhandle ->query($query); } public function resultset() { return $this->

我正在尝试使用pdo从mysql过程中获取多个结果, 我可以从#1得到结果,但#2永远不会向浏览器返回值。这里发生了什么

顺便说一下,onequery实际上是这样的:

public function onequery($query)
 {
     $this -> statement = $this ->dbhandle ->query($query);
 }
 public function resultset()
 {
        return $this->statement->fetchAll(PDO::FETCH_ASSOC);
 }
$mysql->onequery($sql);
    do
    {
        $rows = $mysql->resultset();
        if($rows)
        {
            if(intval($rows["laststamp"])>$lastTimeStamp)//get the max timestamp
               $lastTimeStamp = intval($rows["laststamp"]);

            if(in_array($rows[0]["id"],$messageUser))
            {

                  array_push($result,$rows[0]);
                  print_r(json_encode($result));//#1
            }
        }
        else 
          break;
    }while ($mysql->nextRowset());
    $result["lastTimeStamp"] = $lastTimeStamp;
    print_r(json_encode($result));//#2
rreultset实际上是这样的:

public function onequery($query)
 {
     $this -> statement = $this ->dbhandle ->query($query);
 }
 public function resultset()
 {
        return $this->statement->fetchAll(PDO::FETCH_ASSOC);
 }
$mysql->onequery($sql);
    do
    {
        $rows = $mysql->resultset();
        if($rows)
        {
            if(intval($rows["laststamp"])>$lastTimeStamp)//get the max timestamp
               $lastTimeStamp = intval($rows["laststamp"]);

            if(in_array($rows[0]["id"],$messageUser))
            {

                  array_push($result,$rows[0]);
                  print_r(json_encode($result));//#1
            }
        }
        else 
          break;
    }while ($mysql->nextRowset());
    $result["lastTimeStamp"] = $lastTimeStamp;
    print_r(json_encode($result));//#2
对不起,我没有透露太多细节,firebug只是告诉我这是一个“500内部服务器错误”,但我检查了日志文件,没有任何内容。 数据库中的表单类似于

messages:
mes_id    formId    toId      mtimestamp     statue      msgText 
    1        18       19          1             1           ''
    1        18       19          2             1           ''
    1        18       19          3             1           ''
    1        18       19          4             1           ''
    1        17       19          3             1           ''
    1        17       19          4             1           ''
我只想得到fromId发送给toId的msgText的数量 所以结果应该是这样的

formID MAX(mtimestamp) count(msgText)
  18          4            4
  17          4            2
因此,我编写了一个过程来实现这一点,它在phpMyAdmin的sql命令中运行良好; 程序如下:

BEGIN
 DECLARE  done int(1) default 0;
 DECLARE USER INT(11) DEFAULT 0;
 DECLARE USERIDSEQ CURSOR FOR SELECT  distinct fromId from messages WHERE toId = id;
 DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
 OPEN USERIDSEQ;
 mloop:LOOP
     FETCH USERIDSEQ INTO USER;
     IF done=1 THEN 
        LEAVE mloop;
     END IF;
     SELECT fromId as id,max(mtimestamp),min(mtimestamp) as laststamp ,count(msgText) as num from messages where fromId = USER AND statue =1 AND mtimestamp > mtime;
 end LOOP mloop;
 CLOSE USERIDSEQ;
end;

你的“毛病”是什么?错误消息?您需要解释nextRowset()与onequery()和resultset()的关系。还要详细说明所需的数据。存储过程在哪里