3
我有查询:获取原始的SQL在Yii2
$popular = self::find()
->from(self::tableName() . ' as t')
->with('user');
当我尝试打印SQL:
$popular->createCommand()->rawSql
它给我:
SELECT * FROM "themes" "t"
这样我就可以得到充分的使用“加入”的原始查询:
SELECT * FROM "themes" "t" LEFT JOIN "users" u ON u.user_id = t.author_id
它将如何帮助? OP想要获得SQL。 – arogachev