Kohana 3.0: how to get distinct entries?
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!
Does it work using a group by
?
return $this->where('product_image_product', '>=', $id-5)->limit(5)->group_by('product_image_product')->find_all();
精彩评论