Пример #1
0
 public function deleteAction()
 {
     $req = $this->request;
     $id = $req->getQuery("id");
     $query = new CosBeautyCanon();
     $model = $query->findFirst("id = {$id}");
     /*
      * 如果删除的是推荐到首页的数据
      * 开启事务,级联删除cos_point_canon表中的 此条数据
      */
     if ($model->state == 2) {
         try {
             $this->db->begin();
             $model->state = 3;
             $model->save();
             $pointCanon = CosPointCanon::findFirst("canon_id = {$id}");
             $r1 = $pointCanon->delete();
             $this->db->commit();
         } catch (Exception $e) {
             $this->db->rollback();
         }
     } else {
         $model->state = 3;
         $model->save();
     }
     $arr = array("status" => 10000);
     echo json_encode($arr);
 }