Kohana 3.0: Come ottenere voci distinte?
-
27-10-2019 - |
Domanda
In una query Kohana, devo recuperare solo un elemento con lo stesso ID. Ho un metodo nel modello:
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
}
Ma il problema è che, da tutti i risultati di cui sopra, generati dal metodo, devo avere solo quelli che hanno distinto "Product_Image_Product". Questo può essere fatto usando Kohana Orm?
Molte grazie!
Soluzione
Funziona usando un file group by
?
return $this->where('product_image_product', '>=', $id-5)->limit(5)->group_by('product_image_product')->find_all();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow