문제

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top