Answer the question
In order to leave comments, you need to log in
How to make a request in Yii2 to the database?
Good afternoon.
I have a request (I need it in the builder, not in ActiveRecord)
return (new \yii\db\Query())
->select(['*'])
->from('profiles')
->where([
'age' => $age
])
->andFilterWhere(['like', 'name', $name ])
->andFilterWhere(['like', 's_name', $s_name ])
->orderBy('id desc')->all();
Answer the question
In order to leave comments, you need to log in
Good evening.
When you created a model, if you created it through gii, then you also had to create a model for searching.
Create this model and see how it's done.
Use andFilterWhere() like this:
$query->andFilterWhere(['like', 'username', $this->username])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question