コード例 #1
0
ファイル: Incognitoreal.php プロジェクト: tanqinwang/test_own
 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
ファイル: Weight.php プロジェクト: tanqinwang/test_own
 public function addAction()
 {
     $p = $_REQUEST;
     $pType = empty($p['type']) ? Tool_Fnc::ajaxMsg('时间段不能为空') : intval($p['type']);
     $pNumber = empty($p['number']) ? Tool_Fnc::ajaxMsg('体重不能为空') : floatval($p['number']);
     $tTime = time();
     $tDate = date('Y-m-d', $tTime);
     $tMO = new R_WeightModel();
     $tRow = $tMO->field('count(0) c')->where('uid = \'' . $this->tUid . '\' and type = ' . $pType . ' and date = \'' . $tDate . '\'')->fRow();
     if (!empty($tRow['c'])) {
         Tool_Fnc::ajaxMsg('该记录已经添加');
     }
     $tData = array('uid' => $this->tUid, 'type' => $pType, 'number' => $pNumber, 'created' => $tTime, 'date' => $tDate, 'month' => date('Y-m', $tTime), 'year' => date('Y', $tTime));
     if (!$tMO->insert($tData)) {
         Tool_Fnc::ajaxMsg('添加失败 ');
     }
     $tDWLMO = new DryweightlogModel();
     $tDWLMO->is_dryweight($this->tUid, $tDate);
     Tool_Fnc::ajaxMsg('添加成功', 1);
 }