Answer the question
In order to leave comments, you need to log in
How to execute ORDER BY RAND LIMIT 5 query in Yii without using CDbCriteria?
Good afternoon.
It is necessary to get several records from the table in random order. At the same time, it is desirable to retain the ability to access relations through relations
1 . For example Product::model()->findAll ...
, what next? This method is interesting.
I would like to get an object-oriented model
2. Is it possible to achieve an object-oriented model using cdbcriteria?
Answer the question
In order to leave comments, you need to log in
Product::model()->findAll(
array(
"condition" => "active=1 AND test_category_id=3",
"order" => "rand()",
"limit" => 5,
)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question