我在函数中有一个选择查询,该查询在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;
}
选择查询结果:
邮递员的实际结果
在原始标签中,所有结果都在获取
在“漂亮”标签中,它显示Bad String
答案 0 :(得分:0)
好,找到答案了。
使结果集循环。
public function customquery($sql) {
foreach (($this->tableGateway->getAdapter()->driver->getConnection()->execute($sql)) as $row){
$results[] = $row;
}
return $results;
}
答案 1 :(得分:0)
我建议你:
public function customquery($sql) {
$data = $this->tableGateway->getAdapter()->driver->getConnection()->execute($sql);
return iterator_to_array($data);
}