从连接表活动查询yii2中选择一列

时间:2017-02-21 18:37:34

标签: join activerecord yii2

我尝试从连接表中选择一列,但我收到错误:未定义的索引:id

$jobHistory = Report::getDb()->cache(function($db){
            return Report::find()
                ->select('job_id')
                ->where(['status' => "Order Delivered"])
                ->andWhere(['>=', 'job_datetime', '2016-09-01'])
                ->andWhere(['<', 'job_datetime', '2016-09-03'])
                ->joinWith(['job' => function($a){
                    $a->select('order_placed');
                }])
                ->asArray()
                ->all();
        });

0 个答案:

没有答案