开发者

Kohana 3.0: how to get distinct entries?

开发者 https://www.devze.com 2023-04-03 06:22 出处:网络
In a Kohana query, I need to retrieve only one element having the same id. I have a method in the model:

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号