1.在查询时加了->select();如下,要加上order_id,即关联的字段(比如:order_id)比如要在select中,否则会报错:undefined index order_id
//查询客户与他们的订单和国家 CustomerModel::find()->select('order_id')->with('orders', 'country')->all();
本文介绍在使用Eloquent ORM进行数据库查询时,如何正确指定关联字段以避免undefined index错误,通过实例展示了如何在select方法中加入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

被折叠的 条评论
为什么被折叠?
