I've been seaching this for hours without success.
I have a products table and I need to take N random products from a list (of 100, from example) of best seller/top rated/most viewed products.
Using raw queries this seems to be trivial. First we take 100 high valorated products, then we reorder and finally take 3 of them.
select * from (select * from `products` order by `valoration` desc limit 100) as products order by RAND() limit 3;
This can be done using DB:table, but I need to do the same query not using raw queries. This is because my Product model has many custom methods and DB:table returns a list of stdObjects instead of a collection of Product models.
How can this be done without raw queries?
Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire