I am getting an empty array every time I run this and I can't figure out what the issue is. I have data that matches the SELECT statement however I never get it back.
$sql = "SELECT `conversation`.`id`, `conversation`.`subject`, MAX(`message`.`date`) AS `last_reply`
FROM `conversation`
LEFT JOIN `message` ON `conversation`.`id` = `message`.`id`
INNER JOIN `con_users` ON `conversation`.`id` = `con_users`.`user_id`
WHERE `con_users`.`user_id` = {$user_id}
AND `con_users`.`deleted` = 0 GROUP BY `conversation`.`id` ORDER BY `last_reply` DESC";
return $this->_db->runQuery($sql);
And this is my runQuery()
$this->_query = $this->_pdo->prepare($sql);
if($this->_query->execute()){
try{
$this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
return $this->_results;
}catch(Exception $e){
// Catch Error
}
return true;
}else{
return false;
}
If anyone can tell me what am I doing wrong it would be greatly appreciated.
Thanks