У меня есть 4 типа допинга < /code>.
Мне нужна некоторая сортировка на странице категорий.
те, у кого допинги типа 1 и 4, будут указаны как DESC вверху, с типами 1 внизу, с типами 4 внизу и нормальными продуктами в последнем ряду, в соответствии с датой формирования. Напишите имя легирования. < /p>
public function getdopingoneandfor($category_id)
{
$this->db->select('products.*, products.id as product_id, products_details.price as product_price');
$this->db->from('products');
$this->db->join('products_details', 'products_details.product_id = products.id');
$this->db->join('dopings', 'dopings.product_id = products.id');
$this->db->where('products.status', 1);
$this->db->where_in('dopings.type', array(1, 4));
$this->db->where('dopings.end_date >= CURDATE()');
$this->db->where('products.category_id', $category_id);
$this->db->group_by('products.id');
$this->db->order_by('MAX(dopings.created_at)', 'DESC');
$query = $this->db->get();
return $query->result();
}
Подробнее здесь: https://stackoverflow.com/questions/775 ... by-dopings