yiisoft/yii2 · error · yii\db\Exception

A join clause must be specified as an array of join type, jo

Error message

A join clause must be specified as an array of join type, join table, and optionally join condition.

What it means

Error "A join clause must be specified as an array of join type, join table, and optionally join condition." thrown in yiisoft/yii2.

Source

Thrown at framework/db/QueryBuilder.php:1306

        return 'FROM ' . implode(', ', $tables);
    }

    /**
     * @param array $joins
     * @param array $params the binding parameters to be populated
     * @return string the JOIN clause built from [[Query::$join]].
     * @throws Exception if the $joins parameter is not in proper format
     */
    public function buildJoin($joins, &$params)
    {
        if (empty($joins)) {
            return '';
        }

        foreach ($joins as $i => $join) {
            if (!is_array($join) || !isset($join[0], $join[1])) {
                throw new Exception('A join clause must be specified as an array of join type, join table, and optionally join condition.');
            }
            // 0:join type, 1:join table, 2:on-condition (optional)
            list($joinType, $table) = $join;
            $tables = $this->quoteTableNames((array)$table, $params);
            $table = reset($tables);
            $joins[$i] = "$joinType $table";
            if (isset($join[2])) {
                $condition = $this->buildCondition($join[2], $params);
                if ($condition !== '') {
                    $joins[$i] .= ' ON ' . $condition;
                }
            }
        }

        return implode($this->separator, $joins);
    }

    /**

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/db/QueryBuilder.php:1306 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/8557984074f0019d. Report an issue: GitHub.