public static function getUnreadConversations($login) { $conversations = array(); $rows = Db::fetchAll("SELECT idvisitor, lastviewed, lastsent FROM " . Common::prefixTable('chat_history_admin') . " WHERE login = ? AND lastsent > lastviewed", array($login)); $rows = ChatCommon::formatRows($rows); foreach ($rows as $row) { $conversations[$row['idvisitor']] = $row; } return $conversations; }
public function getListConversations() { $rows = Db::fetchAll("SELECT\n\t\t\tidvisitor, \n\t\t\tMAX(idmessage) AS maxid, \n\t\t\t(SELECT t2.content FROM " . Common::prefixTable('chat') . " AS t2 WHERE t2.idvisitor = t1.idvisitor ORDER BY t2.idmessage DESC LIMIT 1) AS content,\n\t\t\t(SELECT t2.microtime FROM " . Common::prefixTable('chat') . " AS t2 WHERE t2.idvisitor = t1.idvisitor ORDER BY t2.idmessage DESC LIMIT 1) AS microtime,\n\t\t\t(SELECT t3.name FROM " . Common::prefixTable('chat_personnal_informations') . " AS t3 WHERE t3.idvisitor = t1.idvisitor) AS name,\n\t\t\t(SELECT t3.email FROM " . Common::prefixTable('chat_personnal_informations') . " AS t3 WHERE t3.idvisitor = t1.idvisitor) AS email\n\t\tFROM " . Common::prefixTable('chat') . " AS t1\n\t\tWHERE idsite = ?\n\t\tGROUP BY idvisitor\n\t\tORDER BY microtime DESC", array($this->idsite)); $rows = ChatCommon::formatRows($rows); return $rows; }