There is the following code to get data from the database via Yii
$query = Task::find() ->where([Task::tableName().'.parent_id' => 0]); $query->leftJoin(TaskModel::tableName()); $query->leftJoin(ClientEntity::tableName()); $query->andWhere([TaskModel::tableName().'.task_id' => Task::tableName().'.id']); $query->andWhere([ClientEntity::tableName().'.client_id' => TaskModel::tableName().'.model_id']); $rows = $query ->offset($pages->offset) ->limit($pages->limit) ->orderBy([ Task::tableName().'.status' => SORT_DESC, Task::tableName().'.`estimated_date`=0' => SORT_ASC, Task::tableName().'.estimated_date' => SORT_ASC ]) ->all(); It seems everything is observed, but in the end I get
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (`task`.`parent_id`=0) AND (`task_model`.`task_id`='{{%task}}.id') AND (`c' at line 1 I tried to write the names of the tables in variables, put the operators in quotes separately, but as a result I always get the same thing.
`task.parent_id= 0`, which is missing from the code snippet shown. And in general it seems to me that you have a little missing binding condition in leftJoin ... - Akina$query = Task::find()->where([Task::tableName().'.parent_id' => 0]);- Ingwar