예제 #1
0
 private function move()
 {
     $tRedis = Cache_Redis::instance();
     $tKeys = $tRedis->hKeys('dakang_incognito_real');
     if (!count($tKeys)) {
         return;
     }
     $tIBPMO = new I_BloodpressureModel();
     $tRBPMO = new R_BloodpressureModel();
     $tIFAMO = new I_FoodaddModel();
     $tRFAMO = new R_FoodaddModel();
     $tIWMO = new I_WeightModel();
     $tRWMO = new R_WeightModel();
     foreach ($tKeys as $tDid) {
         $tRWMO->begin();
         $tUid = $tRedis->hget('dakang_incognito_real', $tDid);
         if (empty($tUid)) {
             continue;
         }
         $tRedis->hdel('dakang_incognito_real', $tDid);
         #血压
         $tIBPDatas = $tIBPMO->field('*')->where('did = \'' . $tDid . '\'')->fList();
         foreach ($tIBPDatas as $tRow) {
             $tID = $tRow['id'];
             unset($tRow['id']);
             unset($tRow['did']);
             $tRow['uid'] = $tUid;
             if (!$tRBPMO->insert($tRow)) {
                 $tRWMO->back();
                 continue;
             }
             $tSql = 'delete from ' . $tIBPMO->table . ' where id = ' . $tID;
             if (!$tIBPMO->exec($tSql)) {
                 $tRWMO->back();
                 continue;
             }
         }
         #饮食记录
         $tIFADatas = $tIFAMO->field('*')->where('did = \'' . $tDid . '\'')->fList();
         foreach ($tIFADatas as $tRow) {
             $tID = $tRow['id'];
             unset($tRow['id']);
             unset($tRow['did']);
             $tRow['uid'] = $tUid;
             if (!$tRFAMO->insert($tRow)) {
                 $tRWMO->back();
                 continue;
             }
             $tSql = 'delete from ' . $tIFAMO->table . ' where id = ' . $tID;
             if (!$tIFAMO->exec($tSql)) {
                 $tRWMO->back();
                 continue;
             }
         }
         #体重
         $tIWDatas = $tIWMO->field('*')->where('did = \'' . $tDid . '\'')->fList();
         foreach ($tIWDatas as $tRow) {
             $tID = $tRow['id'];
             unset($tRow['id']);
             unset($tRow['did']);
             $tRow['uid'] = $tUid;
             if (!$tRWMO->insert($tRow)) {
                 $tRWMO->back();
                 continue;
             }
             $tSql = 'delete from ' . $tIWMO->table . ' where id = ' . $tID;
             if (!$tIWMO->exec($tSql)) {
                 $tRWMO->back();
                 continue;
             }
         }
         $tRWMO->commit();
     }
 }
예제 #2
0
 public function delAction()
 {
     $p = $_REQUEST;
     $pType = empty($p['type']) ? Tool_Fnc::ajaxMsg('类型不为空') : trim($p['type']);
     $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']);
     if (!Tool_Validate::is_date($pDate)) {
         Tool_Fnc::ajaxMsg('日期不正确');
     }
     $tMO = new R_WeightModel();
     $tSql = 'delete from ' . $tMO->table . ' where type = ' . $pType . ' and date = \'' . $pDate . '\' and uid = \'' . $this->tUid . '\'';
     if (!$tMO->exec($tSql)) {
         Tool_Fnc::ajaxMsg('删除失败');
     }
     Tool_Fnc::ajaxMsg('删除成功', 1);
 }