php - How to create ActiveRecord query for this MySQL query? -


i got mysql query, how can write activerecord?

select * `sel_posts` `login_id` = 22 or 23 or 24 ... (this ids array $ifollow) order `datetime` desc limit 0 , 20 

first of all, it's better replace or in in where part.

assuming model named selpost, here how can activequery:

$models = selpost::find()     ->where(['login_id' => $ifollow])     ->orderby(['datetime' => sort_desc])     ->limit(20)     ->all(); 

where smart enough automatically add in operator in case of $ifollow being array.

official documentation:


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -