yii2 left join 查询



SpellTeamLine::find()->select('a.*,b.order_sn,b.member_id')->alias('a')->joinWith(['spellTeamSub b'],false)->where(['spell_team_id'=>$id])->orderBy('id desc')->asArray()->all();

手册:
* Order::find()->joinWith('books', true, 'INNER JOIN')->all();
* // find all orders, eager loading "books", and sort the orders and books by the book names.
* Order::find()->joinWith([
* 'books' => function (\yii\db\ActiveQuery $query) {
* $query->orderBy('item.name');
* }
* ])->all();
* // find all orders that contain books of the category 'Science fiction', using the alias "b" for the books table
* Order::find()->joinWith(['books b'], true, 'INNER JOIN')->where(['b.category' => 'Science fiction'])->all();
* ```
*


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM