query()->insertGetId($data); // 返回结果 return $id; } /** * 添加数据 * */ public function edit($id,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 返回结果 return $result; } /** * 添加数据 * * @param int $orderId 订单ID * @param array $data 数据 */ public function editByOrderId($orderId,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where([['order_id','=',$orderId]])->update($data); // 返回结果 return $result; } /** * 查询数据 * */ public function getOneByOrderId($orderId){ // 写入数据表 $result = $this->query()->where([['order_id','=',$orderId]])->first(); // 返回结果 return $result; } }