当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtils::getConnection方法代码示例

本文整理汇总了PHP中DBUtils::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtils::getConnection方法的具体用法?PHP DBUtils::getConnection怎么用?PHP DBUtils::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtils的用法示例。


在下文中一共展示了DBUtils::getConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: log

 public function log()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("userxplog > log > start userId : " . $this->userId . " xp : " . $this->xp . " type : " . $this->type . " time : " . $this->time . " gameId : " . $this->gameId . " result : " . $this->result . " opponentId : " . $this->opponentId);
     if (!empty($this->userId)) {
         $userXPLog = new GameUserXpLog();
         $userXPLog->setUserId($this->userId);
         $userXPLog->setXp($this->xp);
         $userXPLog->setTime($this->time);
         $userXPLog->setType($this->type);
         $userXPLog->setGameId($this->gameId);
         $userXPLog->setResult($this->result);
         $userXPLog->setOpponentId($this->opponentId);
         try {
             $user = GameUsers::getGameUserById($this->userId);
             if (!empty($user)) {
                 $userXPLog->setUserLevel($user->userLevelNumber);
                 $userXPLog->setUserCoin($user->coins);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
             }
         } catch (Exception $exc) {
             $log->logError("userxplog > log > User Error : " . $exc->getTraceAsString());
         }
         try {
             $userXPLog->insertIntoDatabase(DBUtils::getConnection());
             $log->logInfo("userxplog > log > Success");
         } catch (Exception $exc) {
             $log->logError("userxplog > log > Error : " . $exc->getTraceAsString());
         }
     } else {
         $log->logError("userxplog > log > user Id is empty ");
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:33,代码来源:userxplog.class.php

示例2: autoLogin

 public static function autoLogin($rememberme = true)
 {
     if (isset($_SESSION["userId"])) {
         $userId = $_SESSION["userId"];
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             UtilFunctions::storeSessionUser($user, $rememberme);
             return $user;
         }
     }
     if (isset($_COOKIE["auth"]) && false) {
         $cookie = $_COOKIE["auth"];
         $arr = explode('&', $cookie);
         $userName = substr($arr[0], 4);
         $hash = substr($arr[1], 5);
         $user = GameUsers::getGameUserByUserName($userName);
         if (!empty($user)) {
             if ($hash == md5($user->getPassword())) {
                 $user->setLastLoginDate(time());
                 $user->setLoginCount($user->getLoginCount() + 1);
                 $user->updateToDatabase(DBUtils::getConnection());
                 Queue::checkUserFriends($user->userId);
                 UtilFunctions::storeSessionUser($user, $rememberme);
                 return $user;
             } else {
                 UtilFunctions::forgetMe();
             }
         }
     }
     return false;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:31,代码来源:Functions.php

示例3: setConstant

 public static function setConstant($key, $value = null)
 {
     if (!empty($key)) {
         GameConstantUtil::setCacheConstant($key, $value);
         $setting = GameConstants::findByExample(DBUtils::getConnection(), GameConstants::create()->setKey_($key));
         if (!empty($setting)) {
             if (sizeof($setting) > 0) {
                 $setting = $setting[0];
                 $k = $setting->getKey_();
                 if (empty($k)) {
                     $setting = null;
                 }
             } else {
                 $setting = null;
             }
         }
         if (!empty($setting)) {
             $setting->setValue_($value);
         } else {
             $setting = GameConstants::create();
             $setting->setKey_($key);
             $setting->setValue_($value);
         }
         $setting->updateInsertToDatabase(DBUtils::getConnection());
     }
     return false;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:27,代码来源:GameConstantFunctions.php

示例4: gameResult

 public static function gameResult(GameUsers $user, GameUsers $opponent, $roomGroupId, $action, $gameId = null, $double = 0, $normal = true, $type = null, $time = null)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($user) && !empty($action)) {
         if (empty($action) || !empty($action) && $action != GameUtils::$GAME_RESULT_ACTION_WIN && $action != GameUtils::$GAME_RESULT_ACTION_LOST) {
             $result->result = "Unknown Action";
             return $result;
         }
         GameUtils::updateXP($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         GameUtils::updateCoin($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         GameUtils::updateCounts($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         if ($action == GameUtils::$GAME_RESULT_ACTION_WIN && ($type == GameUtils::$GAME_RESULT_ACTION_TYPE_LEFT || $type == GameUtils::$GAME_RESULT_ACTION_TYPE_TIMESUP) && !empty($opponent)) {
             if (empty($time)) {
                 $time = time();
             }
             Queue::userLostConnLost($opponent->userId, $user->userId, $roomGroupId, GameUtils::$GAME_RESULT_ACTION_LOST, $gameId, $double, $normal, $type, $time);
         }
         try {
             $user->updateToDatabase(DBUtils::getConnection());
             $result->success = true;
             $result->result = new stdClass();
             $result->result->user = $user;
         } catch (Exception $exc) {
             $result->success = true;
             $result->result = $exc->getTraceAsString();
         }
         return $result;
     } else {
         $result->result = "User not found";
         return $result;
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:33,代码来源:GameFunctions.php

示例5: checkFriends

 public function checkFriends()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("user > checkFriends > start userId : " . $this->userId);
     $user = GameUsers::getGameUserById($this->userId);
     if (!empty($user)) {
         $userId = $user->userId;
         if (!empty($userId)) {
             $fbFriends = FriendUtils::getUserFacebookFriends($user);
             if (!empty($fbFriends) && sizeof($fbFriends) > 0) {
                 $fbFriendIds = null;
                 foreach ($fbFriends as $fbFriend) {
                     if (!empty($fbFriend) && isset($fbFriend["id"])) {
                         if (empty($fbFriendIds)) {
                             $fbFriendIds = $fbFriend["id"];
                         } else {
                             $fbFriendIds = $fbFriendIds . "," . $fbFriend["id"];
                         }
                     }
                 }
                 $fbFriendUserIds = FriendUtils::getUserIdsFromFacebookIds($fbFriendIds);
                 if (!empty($fbFriendUserIds)) {
                     $friendIds = FriendUtils::getUserFriendIds($userId);
                     foreach ($fbFriendUserIds as $fbFriendId) {
                         if (!empty($fbFriendId)) {
                             $add = false;
                             if (!empty($friendIds) && sizeof($friendIds) > 0) {
                                 if (!in_array($fbFriendId, $friendIds)) {
                                     $add = true;
                                 }
                             } else {
                                 $add = true;
                             }
                             if ($add) {
                                 $friend = new GameUserFriends();
                                 $friend->setUserId($this->userId);
                                 $friend->setType("facebook");
                                 $friend->setFriendId($fbFriendId);
                                 try {
                                     $friend->insertIntoDatabase(DBUtils::getConnection());
                                 } catch (Exception $exc) {
                                     error_log("userclass>checkFriends userId : " . $this->userId . " friend Id : " . $fbFriendId . " Error : " . $exc->getMessage() . " Trace :" . $exc->getTraceAsString());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $log->logInfo("user > checkFriends > end userId : " . $this->userId);
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:52,代码来源:user.class.php

示例6: updateUserImage

 public static function updateUserImage($userId)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($userId)) {
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             $tmpImgPath = UserProfileImageUtils::downloadFBProfileImage($user->facebookId);
             $profileImageUrl = null;
             if (!empty($tmpImgPath)) {
                 try {
                     $s3 = new S3(AWS_API_KEY, AWS_SECRET_KEY);
                     $s3->setEndpoint(AWS_S3_ENDPOINT);
                     $imageName = "pi_" . $userId . ".png";
                     $s3Name = "profile.images/" . $userId . "/" . $imageName;
                     $res = $s3->putObjectFile($tmpImgPath, AWS_S3_BUCKET, $s3Name, S3::ACL_PUBLIC_READ);
                     if ($res) {
                         $profileImageUrl = 'http://' . AWS_S3_BUCKET . '.s3.amazonaws.com/' . $s3Name;
                         try {
                             unlink($tmpImgPath);
                         } catch (Exception $exc) {
                             error_log($exc->getTraceAsString());
                         }
                     } else {
                         $result->result = json_encode($res);
                     }
                 } catch (Exception $exc) {
                     $result->result = $exc->getTraceAsString();
                 }
             } else {
                 $profileImageUrl = USER_DEFAULT_IMAGE_URL;
             }
             if (!empty($profileImageUrl)) {
                 $user->setProfilePicture($profileImageUrl);
                 try {
                     $user->updateToDatabase(DBUtils::getConnection());
                     $result->success = true;
                     $result->result = null;
                 } catch (Exception $exc) {
                     $result->result = $exc->getTraceAsString();
                 }
             }
         } else {
             $result->result = "user not found";
         }
     } else {
         $result->result = "user id empty";
     }
     return $result;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:50,代码来源:UserProfileImageFunctions.php

示例7: useRequest

 public static function useRequest($id, $used = 1)
 {
     if (!empty($id)) {
         try {
             $req = GameFbRequest::findById(DBUtils::getConnection(), $id);
             if (!empty($req)) {
                 $req->setUsed($used);
                 $req->setUsedTime(time());
                 $req->updateToDatabase(DBUtils::getConnection());
             }
         } catch (Exception $exc) {
             error_log($exc->getTraceAsString());
         }
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:15,代码来源:GameFbRequest.class.php

示例8: getRoomGroupById

 public static function getRoomGroupById($id)
 {
     if (!empty($id)) {
         $roomGroups = GameRoomGroups::findById(DBUtils::getConnection(), $id);
         if (count($roomGroups) > 0) {
             $roomGroup = $roomGroups[0];
             unset($roomGroups);
             if (!empty($roomGroup)) {
                 $roomGroupId = $roomGroup->roomGroupId;
                 if (!empty($roomGroupId)) {
                     return $roomGroup;
                 }
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:17,代码来源:GameRoomGroups.class.php

示例9: getRecordByUserId

 public static function getRecordByUserId($userId)
 {
     if (!empty($userId)) {
         $records = GameLeaderboardDaily::findByExample(DBUtils::getConnection(), GameLeaderboardDaily::create()->setUserId($userId));
         if (count($records) > 0) {
             $record = $records[0];
             unset($records);
             if (!empty($record)) {
                 $recId = $record->getId();
                 if (!empty($recId)) {
                     return $record;
                 }
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:17,代码来源:GameLeaderboardDaily.class.php

示例10: getUserLevelByName

 public static function getUserLevelByName($levelName)
 {
     if (!empty($levelName)) {
         $userLevels = GameUserLevel::findByExample(DBUtils::getConnection(), GameUserLevel::create()->setLevelName($levelName));
         if (count($userLevels) > 0) {
             $userLevel = $userLevels[0];
             unset($userLevels);
             if (!empty($userLevel)) {
                 $userLevelId = $userLevel->levelId;
                 if (!empty($userLevelId)) {
                     return $userLevel;
                 }
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:17,代码来源:GameUserLevel.class.php

示例11: insertLog

 public static function insertLog($userId)
 {
     if (!empty($userId)) {
         $log = GameUserLoginLog::create();
         $log->setUserId($userId);
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             $log->setBrowser($_SERVER['HTTP_USER_AGENT']);
         }
         $log->setTime(time());
         $log->setDate(date("Ymd"));
         if (isset($_SERVER['REMOTE_ADDR'])) {
             $log->setIp($_SERVER['REMOTE_ADDR']);
         }
         try {
             $log->insertIntoDatabase(DBUtils::getConnection());
         } catch (Exception $exc) {
             error_log($exc->getTraceAsString());
         }
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:20,代码来源:GameUserLoginLog.class.php

示例12: getGameItemByCode

 public static function getGameItemByCode($itemCode)
 {
     if (!empty($itemCode)) {
         $gameItems = GameItems::findByExample(DBUtils::getConnection(), GameItems::create()->setActive(1)->setItemCode($itemCode));
         if (count($gameItems) > 0) {
             $gameItem = $gameItems[0];
             unset($gameItems);
             if (!empty($gameItem)) {
                 $itemId = $gameItem->getId();
                 if (!empty($itemId)) {
                     return $gameItem;
                 }
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:17,代码来源:GameItems.class.php

示例13: date

    if (empty($user->userFirstname)) {
        $errorHTML .= "<p/>Enter User First Name";
    }
    if (empty($user->userLastname)) {
        $errorHTML .= "<p/>Enter User Last Name";
    }
    if (empty($user->password)) {
        $user->setPassword(DBUtils::get_uuid());
    }
    if (empty($errorHTML)) {
        if (empty($user->registerDate)) {
            $user->setRegisterDate(time());
        }
        $user->updateInsertToDatabase(DBUtils::getConnection());
        $bot->setUserId($user->userId);
        $bot->updateInsertToDatabase(DBUtils::getConnection());
        try {
            $const = "v1.3_" . date("Ymd");
            GameConstantUtil::setConstant("constant.bot.version", $const);
        } catch (Exception $exc) {
            error_log($exc->getMessage());
            error_log($exc->getTraceAsString());
        }
        header("Location: " . HOSTNAME . "admin/bots.php");
        exit(1);
    }
}
$page_var = "bots";
include_once __ROOT__ . 'admin/admin_header_layout.php';
?>
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:30,代码来源:newbot.php

示例14: getDailyBonusConstants

 public static function getDailyBonusConstants()
 {
     try {
         $SQL = "SELECT * FROM " . TBL_GAME_CONSTANTS . " WHERE key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "1' OR key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "2' OR" . " key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "3' OR key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "4' OR key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "5' OR" . " key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "6' OR key_='" . BonusUtils::$CONSTANT_DAILYBONUS . "7' ORDER BY key_ ASC";
         $dailyBonuses = GameConstants::findBySql(DBUtils::getConnection(), $SQL);
         $result = array();
         for ($i = 1; $i < 8; $i++) {
             $dailybonus = new stdClass();
             $dailybonus->order = $i;
             if (!empty($dailyBonuses) && sizeof($dailyBonuses) >= $i) {
                 $tmp = $dailyBonuses[$i - 1];
                 if ($tmp != null) {
                     $dailybonus->coin = $tmp->getValue_();
                 }
             }
             if (empty($dailybonus->coin)) {
                 $dailybonus->coin = $i * 100;
             }
             array_push($result, $dailybonus);
         }
         return $result;
     } catch (Exception $exc) {
         var_dump($exc);
         error_log($exc->getTraceAsString());
     }
     $result = array();
     for ($i = 1; $i < 8; $i++) {
         $dailybonus = new stdClass();
         $dailybonus->order = $i;
         $dailybonus->coin = $i * 100;
         array_push($result, $dailybonus);
     }
     return $result;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:34,代码来源:BonusFunctions.php

示例15: intval

}
if (strtoupper($orderBy) == "ASC") {
    $orderBy = "ASC";
} else {
    $orderBy = "DESC";
}
$sortBy = "time";
if (isset($_GET["sortBy"])) {
    $sortBy = $_GET["sortBy"];
} else {
    if (isset($_POST["sortBy"])) {
        $sortBy = $_POST["sortBy"];
    }
}
$SQL = "SELECT * FROM " . TBL_GAME_USER_FEEDBACK . " ORDER BY " . $sortBy . " " . $orderBy . " LIMIT " . ($page - 1) * $pageCount . "," . $pageCount;
$feedBackList = GameUserFeeedback::findBySql(DBUtils::getConnection(), $SQL);
$total_feedback = GameUserFeeedback::getTotalCount();
$max_page = intval($total_feedback / $pageCount);
if ($total_feedback % $pageCount > 0) {
    $max_page++;
}
$queryString = "";
if (isset($_GET) && sizeof($_GET) > 0) {
    foreach ($_GET as $key => $value) {
        if ($key != "page") {
            $queryString = $queryString . "&" . $key . "=" . $value;
        }
    }
}
if (strtoupper($orderBy) == "ASC") {
    $orderBy = "DESC";
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:31,代码来源:feedbacks.php


注:本文中的DBUtils::getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。