/** * 用戶完成新手教程更新 * @param $mid * @param $param 要更新的參數 */ public function updateUserParam($mid, $param = array()) { if (!($mid = Helper::uint($mid))) { return false; } $update = ""; if (isset($param['mtaskcount'])) { $update .= ",mtaskcount=mtaskcount+1"; } if ($update) { $update = substr($update, 1); $query = "UPDATE {$this->members} SET {$update} WHERE mid={$mid} LIMIT 1"; Loader_Mysql::dbmaster()->query($query); if (Loader_Mysql::dbmaster()->affectedRows()) { //更新 cache $aUser = $this->getOneById($mid, false); $aUser['mtaskcount'] += 1; $cacheKey = Core_Keys::getOneById($mid); $flag = Loader_Memcached::minfo($mid)->set($cacheKey, Values::combine(Values::getmb(), $aUser), 10 * 24 * 3600); } else { $flag = false; } } return $flag; }
/** * 用户资料更新 * @param int $mid * @param array $fields **/ public function updateInfo($mid, $fields = array()) { $update = ""; foreach ($fields as $key => $val) { if (is_null($val)) { continue; } $update .= $key . "='" . $val . "',"; } $update = substr($update, 0, -1); $sql = "UPDATE {$this->memberinfo} SET {$update} WHERE mid={$mid} LIMIT 1"; $flag = Loader_Mysql::dbmaster()->query($sql); if ($flag) { //更新成功 更新缓存 $aUser = Member::factory()->getOneById($mid, false); foreach ($fields as $key => $val) { if (isset($aUser[$key])) { $aUser[$key] = $val; } } //更新缓存 $cacheKey = Core_Keys::getOneById($mid); return Loader_Memcached::minfo($mid)->set($cacheKey, Values::combine(Values::getmb(), $aUser), 3 * 24 * 3600); } return false; }
/** * * 设置游客信息缓存 * @param {int} $ctype 客户端类型 * @param {string} $type 缓存key值类型 * @param {string} $GuestValue * @param {array} $aInfo * @return {ArrayIterator} setGuestCache */ private function setGuestCache($ctype, $strkey, $GuestValue, $aInfo) { if (empty($GuestValue) || empty($aInfo) || !is_array($aInfo)) { return array(); } $aGuestSysKeys = $aCacheInfo = array(); if ($ctype == self::IOSCLIENTTYPE) { $aGuestSysKeys = self::$IOSGUESTKEY; } elseif ($ctype == self::ANDROIDCLIENTTYPE) { $aGuestSysKeys = self::$ANDROIDGUESTKEY; } else { return array(); } $cTypeKey = self::$CACHETYPE[$strkey]; $CacheKey = Core_keys::guestLoginMarkKey($GuestValue, $ctype, $cTypeKey); $aCacheInfo = Values::combine($aGuestSysKeys, $aInfo); if ($aCacheInfo[0]) { Loader_Redis::redisGuestMember()->set($CacheKey, json_encode($aCacheInfo), false, true, 86400 * self::GUESTTIMEPUTDAY); } return true; }