指定字段:

$historyinfo = Healthy::find()->select(['healthy_id','pet_name','hardware_name','hardware_color','remove_binding'])->where(['user_id'=>$user_id,'is_activation'=>'2'])->asArray()->all();

获取添加数据的id:

 $id = $model->attributes['healthy_id'];
 
Yii2框架查询指定字段和获取添加数据的id-LMLPHP

05-07 15:36