php api 响应未显示所有结果

php api response not showing all results

我在函数中有一个 select 查询,它在 sql 命令提示符下执行,显示所有结果。

但在邮递员回复中,UserInfo 仅显示 1 条记录作为回复。

protected function getUserSession(){
    $data = $this->params; 

    $sqlquery = "SELECT `Uid` as UID,`CreatedDate"
            . "` as CreatedDate,`Action_key` as ActionKey FROM `UsersOptStatus` ORDER BY Uid DESC LIMIT 10"; 
    $userInfoArray = array();       
    $userInfoArray = $this->getUsersOptStatusTable()->customquery($sqlquery);
    print_r($userInfoArray);

    //$uid =  $this->getUsersNewTable()->uidFromApiKey($data['UserId']);

   return array("errstr"=>"Fetching success.","success"=>1,"data"=>array('UserInfo'=>$userInfoArray));
}


public function customquery($sql) {
    $data = $this->tableGateway->getAdapter()->driver->getConnection()->execute($sql);
    return $data;
}

Select 查询结果:

Postman 中的实际结果

在原始选项卡中,所有结果都在提取

在 Pretty 选项卡中,它显示 Bad String

好的找到答案了。

有结果集的循环。

public function customquery($sql) {
    foreach (($this->tableGateway->getAdapter()->driver->getConnection()->execute($sql)) as $row){
        $results[] = $row;
    }
    return $results;

}

我建议你:

public function customquery($sql) {
    $data = $this->tableGateway->getAdapter()->driver->getConnection()->execute($sql);
    return iterator_to_array($data);
}