I have a select query in a function, which executed in sql command prompt, displays all results.
But in postman response, UserInfo
is showing only 1 record as response.
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 Query's result:
Actual Result in Postman
In raw tab, all results are fetching
In Pretty tab, it shows Bad String
Ok found the answer.
Had the loop the result sets .
public function customquery($sql) {
foreach (($this->tableGateway->getAdapter()->driver->getConnection()->execute($sql)) as $row){
$results[] = $row;
}
return $results;
}