public function editAction() { $p = $_REQUEST; $pDate = empty($p['date']) ? Tool_Fnc::ajaxMsg('日期不能为空') : trim($p['date']); if (!Tool_Validate::is_date($pDate)) { Tool_Fnc::ajaxMsg('日期不正确'); } $pHigh = empty($p['high']) ? Tool_Fnc::ajaxMsg('高压不能为空') : floatval($p['high']); $pLow = empty($p['low']) ? Tool_Fnc::ajaxMsg('低压不能为空') : floatval($p['low']); $pType = empty($p['type']) ? 0 : intval($p['type']); $arr = array(1, 2); if (!in_array($pType, $arr)) { Tool_Fnc::ajaxMsg('操作错误'); } $tTime = time(); $tMO = new R_BloodpressureModel(); $tRow = $tMO->field('id')->where('uid = ' . $this->tUid . ' and date = \'' . $pDate . '\' and type = ' . $pType)->fRow(); $tData = array('type' => $pType, 'high' => $pHigh, 'low' => $pLow, 'uid' => $this->tUid, 'date' => $pDate, 'created' => $tTime); if (!empty($tRow['id'])) { $tData['id'] = $tRow['id']; if (!$tMO->update($tData)) { Tool_Fnc::ajaxMsg('操作失败 001'); } } else { if (!$tMO->insert($tData)) { Tool_Fnc::ajaxMsg('操作失败 002'); } } Tool_Fnc::ajaxMsg('操作成功', 1); }
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(); } }