Equilavent ActiveRecord methods

Hi

What is the equivalent method with native sql in WHERE of model ActiveRecord in Yii2 ?

So, In Yii 1.x I could use that


Orders::model()->findAll('rank>:rnk AND datetime=NOW() AND customer_id>:l_id AND customer_id<:u_id', array(':rnk'=>7,':l_id'=>5,':u_id'=>50));

For Yii2

I don’t want to use multiple or complex “where” “addWhere” etc Yii2

I found useful the findBySql. Do I have to use also "select * from name_of_table …"?


Orders::findBySql('rank>:rnk AND datetime=NOW() AND customer_id>:l_id AND customer_id<:u_id', array(':rnk'=>7,':l_id'=>5,':u_id'=>50))->all();



Thanks!

Is the below code the most suitable ?


Orders::find()->where('rank>:rnk AND datetime=NOW() AND customer_id>:l_id AND customer_id<:u_id', array(':rnk'=>7,':l_id'=>5,':u_id'=>50))->all();

Yes.