/**
  * 将uid和gameuid绑定
  *
  * @param string $uid 用户uid
  * @param int $gameuid 用户gameuid
  * @return void
  */
 public function createMapping($uid, $gameuid)
 {
     if ($this->logger->isDebugEnabled()) {
         $this->logger->writeDebug("mapping uid[{$uid}] with gameuid[{$gameuid}]");
     }
     $req = RequestFactory::createInsertRequest(get_app_config());
     $req->setTable($this->getTableName());
     $req->setColumns("uid,gameuid");
     $req->addValues(array($uid, $gameuid));
     $req->execute();
 }
 protected function insertDBBatch($change, $cache_type = null)
 {
     if (empty($change)) {
         return false;
     }
     foreach ($change as $ch) {
         $req = RequestFactory::createInsertRequest(get_app_config());
         $req->setTable($this->getTableName());
         $req->setKey($this->getKeyName(), $ch[$this->getKeyName()]);
         $req->setColumns(implode(',', array_keys($ch)));
         break;
     }
     foreach ($change as $ch) {
         $req->addValues(array_values($ch));
     }
     if (isset($cache_type)) {
         $req->setCacheType($cache_type);
     }
     $req->execute();
     return true;
 }
 private function commitToDB_bak($logs = null)
 {
     $key = $this->getMemkey();
     if ($logs == null) {
         $logs = $this->getFromCache($key, $this->gameuid);
     }
     if (empty($logs)) {
         return;
     }
     if (PLATFORM == "test" || PLATFORM == "facebook_tw") {
         $contents = '';
         $fomat = "g[%d]a[%d]c[%d]m[%d]e[%d]d[%d]it[%d]t[%d] \r\n";
         foreach ($logs as $log) {
             $contents .= sprintf($fomat, $this->gameuid, $log['action_type'], intval($log['coin']), intval($log['money']), intval($log['experience']), intval($log['coupon']), intval($log['content']), $log['create_time']);
         }
         if (!empty($contents)) {
             //				$logger = LogFactory::getLogger(array(
             //					'prefix' => "action_log", // 文件名的前缀
             //					'log_dir' => APP_ROOT.'/log/', // 文件所在的目录
             //					'archive' => ILogger::ARCHIVE_YEAR_MONTH, // 文件存档的方式
             //					'log_level' => 1
             //					));
             $this->logger_self->writeError($contents);
         }
         $logs = array();
         $this->setToCache($key, $logs, $this->gameuid);
     } else {
         // 插入到数据库
         $req = RequestFactory::createInsertRequest(get_app_config($this->gameuid));
         // 不需要缓存数据
         $req->setNoCache(true);
         $req->setKey("gameuid", $this->gameuid);
         $req->setTable($this->getTableName());
         $req->setColumns("gameuid,action_type,coin,money,experience,create_time,content,coupon");
         foreach ($logs as $log) {
             $req->addValues(array($this->gameuid, $log['action_type'], $log['coin'], $log['money'], $log['experience'], $log['create_time'], intval($log['content']), intval($log['coupon'])));
         }
         $affected_rows = $req->execute();
         if ($affected_rows > 0) {
             // 将缓存清空
             $logs = array();
             $this->setToCache($key, $logs, $this->gameuid);
         }
     }
 }