Kohana 3.0: how to get distinct entries?
-
27-10-2019 - |
Question
In a Kohana query, I need to retrieve only one element having the same id. I have a method in the model:
public function next_products_images($id)
{
return $this->where('product_image_product', '>=', $id-5)->limit(5)->find_all();
//for taking the previous five product pictures
}
but the problem is that, from all the above results, generated by the method, I need to have only the ones that have "product_image_product" distinct. Can this be done using Kohana ORM?
Thanks a lot!
Solution
Does it work using a group by
?
return $this->where('product_image_product', '>=', $id-5)->limit(5)->group_by('product_image_product')->find_all();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow