yii2.0 联表查询数据库报错:undefined index order_id

1.在查询时加了->select();如下,要加上order_id,即关联的字段(比如:order_id)比如要在select中,否则会报错:undefined index order_id

//查询客户与他们的订单和国家  
CustomerModel::find()->select('order_id')->with('orders', 'country')->all();  
原文地址:https://www.cnblogs.com/zsczsc/p/9547729.html