class Order { public $model; public $error; public $service = []; public function __construct() { $this->model = new \app\admin\model\counsel\Order(); $serviceModel = new Service(); $serviceList = $serviceModel->select(); foreach ($serviceList as $v){ $this->service[$v['id']]=$v['service_name']; } } /** * 获取订单列表 * @param $page * @param $limit * @throws \think\Exception */ 对于这段代码的影响 public function getOrderList($where,$page,$limit){ $count = $this->model ->alias("order") ->join("counsel_teacher teacher","order.teacher_id=teacher.id") ->where($where)->count(); if($page){ $data = collection($this->model ->alias("order") ->field("order.id,order.order_no,order.teacher_id,order.day,order.name,order.times_ids,order.user_id,order.service_id,order.price,order.createtime,order.status,order.completetime,teacher.teacher_name,teacher.image") ->join("counsel_teacher teacher","order.teacher_id=teacher.id") ->where($where)->page($page,$limit)->order("id desc")->select())->toArray(); }else{ $data = collection($this->model ->alias("order") ->field("order.id,order.order_no,order.teacher_id,order.day,order.name,order.times_ids,order.user_id,order.service_id,order.price,order.createtime,order.status,order.completetime,teacher.teacher_name,teacher.image") ->join("counsel_teacher teacher","order.teacher_id=teacher.id") ->where($where)->order("id desc")->select())->toArray(); } foreach($data as &$v){ $v = $this->getOrderDetail($v); } return ['total'=>$count,'data'=>$data]; }
时间: 2024-01-19 22:03:01 浏览: 69
php class中public,private,protected的区别以及实例分析
这段代码是一个PHP类中的方法,主要作用是获取符合条件的订单列表。具体实现中,它首先通过传入的$where条件来查询订单总数,然后根据传入的$page和$limit参数来分页查询符合条件的订单信息。查询的具体字段包括订单号、教师ID、日期、姓名、时间ID、用户ID、服务ID、价格、创建时间、状态、完成时间、教师姓名和头像。最后,对查询结果进行遍历,调用getOrderDetail方法来获取订单的详细信息,并返回包含订单总数和订单数据的关联数组。
阅读全文