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(); } }
public function delAction() { $p = $_REQUEST; $pId = empty($p['id']) ? Tool_Fnc::ajaxMsg('操作错误') : intval($p['id']); $pFid = empty($p['fid']) ? Tool_Fnc::ajaxMsg('食物ID不能为空') : intval($p['fid']); $pDid = empty($p['did']) ? Tool_Fnc::ajaxMsg('DID不能为空') : trim($p['did']); if (!Tool_Validate::az09($pDid)) { Tool_Fnc::ajaxMsg('did格式不正确'); } $tIFDMO = new I_FoodaddModel(); $tSql = 'delete from ' . $tIFDMO->table . ' where fid = ' . $pFid . ' and did = \'' . $pDid . '\' and id = ' . $pId; if (!$tIFDMO->exec($tSql)) { Tool_Fnc::ajaxMsg('删除失败'); } Tool_Fnc::ajaxMsg('删除成功', 1); }