Alexander:
Конечно, только тапками, пожалуйста не кидайте сильно :D
$this->db->execute('
SELECT
mails.status AS "status",
mails.to AS "id_to_user",
mails.from AS "id_from_user",
user_to.username AS "name_to_user",
user_from.username AS "name_from_user"
FROM mails
INNER JOIN users AS user_to ON mails.to = user_to.id
INNER JOIN users AS user_from ON mails.from = user_from.id
WHERE mails.box = ?
GROUP BY p_to.username, p_from.username
ORDER BY mails.date ASC'
, array($this->user->id));
"GROUP BY" был добавлен в результате попыток решить задачу.
Конечно, только тапками, пожалуйста не кидайте сильно :D
$this->db->execute('
SELECT
mails.status AS "status",
mails.to AS "id_to_user",
mails.from AS "id_from_user",
user_to.username AS "name_to_user",
user_from.username AS "name_from_user"
FROM mails
INNER JOIN users AS user_to ON mails.to = user_to.id
INNER JOIN users AS user_from ON mails.from = user_from.id
WHERE mails.box = ?
GROUP BY p_to.username, p_from.username
ORDER BY mails.date ASC'
, array($this->user->id));
"GROUP BY" был добавлен в результате попыток решить задачу.