Answer the question
In order to leave comments, you need to log in
Yii2 ActiveRecord problem with SQL queries?
Hello!!! I make queries with counting the number of rows, and I noticed that the SQL queries seem to be connected.
For example I created
$query=Custum::find()->joinWith('order')->where(['id'=>101])
$count_custom=$query->count();
Answer the question
In order to leave comments, you need to log in
$query = Custum::find()->joinWith('order')->where(['id'=>101]); // возвращает ActiveRecord с условием where
$count_custom = $query->count(); // считает с условием where
$query->andWhere(условие); // добавляет $query условие andWhere, теперь в нем два условия: where и andWhere
$query->andWhere()
changes the $query object. If you need to apply different conditions, use the (clone $query)->andWhere()
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question