订单表Model写法:
public function getUser(){
return $this->hasOne(User::className(),['user_id'=>'order_id']);
}
/**
* 一个用户有多个订单
*/
public function getOrders(){
return $this->hasMany(Order::className(), ['user_id'=>'order_id']);
}
订单表调用方法:
/**
* @return mixed
*/
public function getList($user_id,$count)
{
$result=Orders::find()->where('user_id='.$user_id)->with('user')->all();
return $result;
}