У меня есть таблица с этой структурой: < /p>
mulach_id, Author_id, заголовок, контент < /p>
Я хотел бы получить все последние записи из таблицы, одна запись для автора, что означает последнюю запись для каждого автора.function getOpinions() {
$data = array();
$this->db->select('*');
$this->db->from('opinions');
$this->db->join('authors', 'opinions.author_id = authors.author_id');
$this->db->order_by('date', 'desc');
$this->db->distinct('author_id');
$Q = $this->db->get();
if ($Q->num_rows() > 0) {
foreach($Q->result_array() as $row) {
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
Подробнее здесь: https://stackoverflow.com/questions/184 ... ork-as-exp