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


PHP DBUtils::mysql_escape方法代码示例

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


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

示例1: getCategoryGameItemWithLanguage

 public static function getCategoryGameItemWithLanguage($categoryCode)
 {
     $SQL = "SELECT items.*,lang.language AS langCode,lang.text AS langText FROM game_items AS items,game_item_language AS lang WHERE items.category='" . DBUtils::mysql_escape($categoryCode) . "' AND items.active=1 AND items.itemCode=lang.itemCode";
     $query = mysql_query($SQL, DBUtils::getManualConnection());
     if (!empty($query)) {
         $list = array();
         $ids = array();
         $i = 0;
         while ($db_field = mysql_fetch_assoc($query)) {
             $item = GameItems::createFromSQLWithLanguage($db_field);
             if (!empty($item)) {
                 $itemId = $item->getId();
                 if (!empty($itemId)) {
                     if (isset($ids[$itemId]) && isset($list[$ids[$itemId]])) {
                         $oldItem = $list[$ids[$itemId]];
                         $oldItem->languages = array_merge($oldItem->languages, $item->languages);
                     } else {
                         array_push($list, $item);
                         $ids[$itemId] = $i;
                         $i++;
                     }
                 }
             }
         }
         unset($ids);
         return $list;
     }
     return array();
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:29,代码来源:GameItems.class.php

示例2: setNextId

 public static function setNextId($field)
 {
     if (!empty($field)) {
         $field = DBUtils::mysql_escape($field);
         $id = rand(1000, 10000000);
         $SQL = "INSERT INTO " . TBL_KEYGENERATOR . " (PK_COLUMN,VALUE_COLUMN)  VALUES ('" . $field . "'," . $id . ")";
         mysql_query($SQL) or die(mysql_error());
         return $id;
     } else {
         return -1;
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:12,代码来源:DBFunctions.php

示例3: getUserFriendIds

 public static function getUserFriendIds($userId)
 {
     if (!empty($userId)) {
         $SQL = "SELECT users.userId FROM " . TBL_GAME_USERS . " users," . TBL_GAME_USER_FRIENDS . " as friend WHERE friend.userId=" . DBUtils::mysql_escape($userId, 1) . " AND friend.friendId=users.userId";
         $query = mysql_query($SQL, DBUtils::getManualConnection());
         if (!empty($query)) {
             $friends = array();
             while ($db_field = mysql_fetch_assoc($query)) {
                 if (isset($db_field["userId"]) && !empty($db_field["userId"])) {
                     array_push($friends, $db_field["userId"]);
                 }
             }
             if (!empty($friends) && sizeof($friends) > 0) {
                 return $friends;
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:19,代码来源:FriendFunctions.php

示例4: getFacebookGiftRequest

 public static function getFacebookGiftRequest($user, $requestIds)
 {
     if (!empty($user) && !empty($requestIds)) {
         $day = intval(GameConstantUtil::getConstant(FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_TIME));
         if ($day <= 0) {
             $day = 7;
         }
         $coin = intval(GameConstantUtil::getConstant(FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_COIN));
         if ($day <= 0) {
             $day = FacebookRequestUtils::$CONSTANT_REQUEST_GIFT_COIN_DEFAULT;
         }
         $SQL = "SELECT * FROM " . TBL_GAME_FB_REQUEST . " WHERE  `to`='" . DBUtils::mysql_escape($user->facebookId) . "' AND used=0 AND type='" . FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT . "' AND requestId IN (" . $requestIds . ") ORDER BY `time` DESC";
         $fbRequests = GameFbRequest::findBySql(DBUtils::getConnection(), $SQL);
         $userArray = array();
         if (!empty($fbRequests) && sizeof($fbRequests) > 0) {
             for ($i = sizeof($fbRequests) - 1; $i >= 0; $i--) {
                 $req = $fbRequests[$i];
                 $req->coin = $coin;
                 if (!empty($req)) {
                     $usrArr = $userArray[$req->userId];
                     if (empty($usrArr)) {
                         $usrArr = array();
                         array_push($usrArr, $req);
                     } else {
                         $last = $usrArr[sizeof($usrArr) - 1];
                         if (intval(date("Ymd", $req->time)) - intval(date("Ymd", $last->time)) >= 7) {
                             array_push($usrArr, $req);
                         } else {
                             GameFbRequest::useRequest($req->getId(), 2);
                         }
                     }
                     $userArray[$req->userId] = $usrArr;
                 }
             }
         }
         unset($fbRequests);
         $result = array();
         foreach ($userArray as $userReq) {
             if (!empty($userReq) && sizeof($userReq) > 0) {
                 try {
                     $coin = 0;
                     $obj = new stdClass();
                     $tmp = GameUsers::findById(DBUtils::getConnection(), $userReq[0]->userId);
                     if (!empty($tmp)) {
                         $obj->user = new stdClass();
                         $obj->user->userId = $tmp->userId;
                         $obj->user->userName = $tmp->userName;
                         $obj->user->userFirstname = $tmp->userFirstname;
                         $obj->user->userLastname = $tmp->userLastname;
                         $obj->user->facebookId = $tmp->facebookId;
                         $obj->user->userXP = $tmp->userXP;
                         $obj->user->userLevelNumber = $tmp->userLevelNumber;
                         $obj->user->coins = $tmp->coins;
                         $ids = "";
                         foreach ($userReq as $req) {
                             if (!empty($req)) {
                                 GameFbRequest::useRequest($req->getId());
                                 $coin = $coin + intval($req->coin);
                                 if (!empty($ids)) {
                                     $ids = $ids . "," . $req->requestId;
                                 } else {
                                     $ids = $ids . "" . $req->requestId;
                                 }
                             }
                         }
                         $obj->coin = $coin;
                         $obj->ids = $ids;
                         $obj->type = FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT;
                         array_push($result, $obj);
                     }
                 } catch (Exception $exc) {
                     error_log($exc->getTraceAsString());
                 }
             }
         }
         unset($userArray);
         foreach ($result as $value) {
             if (!empty($value)) {
                 $time = time();
                 $user->setCoins($user->getCoins() + $value->coin);
                 $user->updateToDatabase(DBUtils::getConnection());
                 $userCoinLog = new GameUserCoinLog();
                 $userCoinLog->setUserId($user->userId);
                 $userCoinLog->setCoin($user->getCoins());
                 $userCoinLog->setDifCoin($value->coin);
                 $userCoinLog->setTime($time);
                 $userCoinLog->setType(FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT);
                 $userCoinLog->setAdd(1);
                 $userCoinLog->setResult(FacebookRequestUtils::$CONSTANT_REQUEST_TYPE_GIFT . "->" . $value->user->userId . "->" . $value->ids);
                 $userCoinLog->setOpponentId($value->user->userId);
                 $userCoinLog->setUserLevel($user->userLevelNumber);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
                 try {
                     $userCoinLog->insertIntoDatabase(DBUtils::getConnection());
                 } catch (Exception $exc) {
                     error_log($exc->getTraceAsString());
                 }
                 Queue::addUserLeaderBoard($user->userId, $value->coin, $time);
             }
         }
//.........这里部分代码省略.........
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:101,代码来源:FacebookRequestFunctions.php

示例5: getUserDailyBonus

 public static function getUserDailyBonus($userId)
 {
     $result = array();
     if (!empty($userId)) {
         try {
             $SQL = "SELECT * FROM " . TBL_GAME_USER_LOGIN_LOG . " WHERE userId=" . DBUtils::mysql_escape($userId, 1) . " GROUP BY date ORDER BY date DESC LIMIT 0,7";
             $dailies = GameUserLoginLog::findBySql(DBUtils::getConnection(), $SQL);
             $dailyBonusConstants = BonusUtils::getDailyBonusConstants();
             $good = 1;
             if (!empty($dailies) && sizeof($dailies) > 1) {
                 for ($i = 1; $i < sizeof($dailies); $i++) {
                     $current = $dailies[$i];
                     $prev = $dailies[$i - 1];
                     if (!empty($current) && !empty($prev)) {
                         $diffs = UtilFunctions::dateDiff(intval($prev->time), intval($current->time));
                         if ($diffs['year'] > 0 || $diffs['month'] > 0 || $diffs['month'] > 0 || $diffs['day'] > 1) {
                             break;
                         } else {
                             $currentD = date("d", $current->time);
                             $prevD = date("d", $prev->time);
                             if ($diffs['day'] == 1 && $diffs["hour"] <= 0 && $diffs["minute"] <= 0 && $diffs["second"] <= 0) {
                                 $good++;
                             } else {
                                 if ($currentD != $prevD) {
                                     $good++;
                                 } else {
                                     break;
                                 }
                             }
                         }
                     } else {
                         break;
                     }
                 }
             }
             for ($i = 0; $i < 7; $i++) {
                 $dailybonus = new stdClass();
                 if (!empty($dailyBonusConstants) && sizeof($dailyBonusConstants) > $i) {
                     $tmp = $dailyBonusConstants[$i];
                     if (!empty($tmp)) {
                         $dailybonus = $tmp;
                     }
                 } else {
                     $dailybonus->order = $i + 1;
                     $dailybonus->coin = ($i + 1) * 100;
                 }
                 if ($i < $good) {
                     $dailybonus->active = true;
                 } else {
                     $dailybonus->active = false;
                 }
                 array_push($result, $dailybonus);
             }
         } catch (Exception $exc) {
             error_log($exc->getTraceAsString());
         }
     }
     return $result;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:59,代码来源:BonusFunctions.php

示例6: getBotByUserId

 public static function getBotByUserId($userId)
 {
     if (!empty($userId)) {
         $SQL = "SELECT bots.id as bot_id, bots.weight_bar as weight_bar, bots.weight_blocked as weight_blocked, bots.weight_faraway as weight_faraway," . " bots.weight_single as weight_single, bots.roomGroupId as roomGroupId, bots.active as bot_active,   users.* FROM " . TBL_GAME_BOTS . " bots," . TBL_GAME_USERS . " as users " . " WHERE bots.userId=" . DBUtils::mysql_escape($userId, 1) . " AND bots.userId=users.userId";
         $query = mysql_query($SQL, DBUtils::getManualConnection());
         if (!empty($query)) {
             while ($db_field = mysql_fetch_assoc($query)) {
                 $bot = GameBots::createFromSQLWithUser($db_field);
                 if (!empty($bot)) {
                     $userId = $bot->getUserId();
                     if (!empty($userId)) {
                         return $bot;
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:19,代码来源:GameBots.class.php

示例7: getGameUserByUserName

 public static function getGameUserByUserName($userName)
 {
     if (!empty($userName)) {
         $SQL = "SELECT level.levelName as level_levelname,level.levelNumber as level_levelnumber,level.maxXP as level_maxXP,level.minXP as level_minXP,users.* FROM " . TBL_GAME_USERS . " users," . TBL_GAME_USER_LEVEL . " as level WHERE users.userName='" . DBUtils::mysql_escape($userName) . "' AND users.userLevelNumber=level.levelNumber ";
         $query = mysql_query($SQL, DBUtils::getManualConnection());
         if (!empty($query)) {
             while ($db_field = mysql_fetch_assoc($query)) {
                 $user = GameUsers::createFromSQLWithLeaderboard($db_field);
                 if (!empty($user)) {
                     $userId = $user->getUserId();
                     if (!empty($userId)) {
                         return $user;
                     }
                 }
             }
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:19,代码来源:GameUsers.class.php

示例8: getProductById

 public static function getProductById($id)
 {
     if (empty($id)) {
         return null;
     }
     $SQL = "SELECT products.*," . "lang.language AS langCode,lang.text AS langText," . "price.currency AS priceCurrency,price.amount AS priceAmount " . "FROM game_fb_products AS products,game_fb_product_language AS lang,game_fb_product_prices AS price " . "WHERE products.id=" . DBUtils::mysql_escape($id, 1) . " AND products.active=1 AND products.Id=lang.fbProductId AND products.Id=price.fbProductId";
     $query = mysql_query($SQL, DBUtils::getManualConnection());
     if (!empty($query)) {
         $list = array();
         $ids = array();
         $i = 0;
         while ($db_field = mysql_fetch_assoc($query)) {
             $item = GameFbProducts::createFromSQLWithLanguagePrice($db_field);
             if (!empty($item)) {
                 $itemId = $item->getId();
                 if (!empty($itemId)) {
                     if (isset($ids[$itemId]) && isset($list[$ids[$itemId]])) {
                         $oldItem = $list[$ids[$itemId]];
                         $oldItem->languages = UtilFunctions::array_unique_merge(array($oldItem->languages, $item->languages));
                         $oldItem->prices = UtilFunctions::array_unique_merge(array($oldItem->prices, $item->prices));
                     } else {
                         array_push($list, $item);
                         $ids[$itemId] = $i;
                         $i++;
                     }
                 }
             }
         }
         unset($ids);
         if (!empty($list) && sizeof($list) > 0) {
             return $list[0];
         }
     }
     return null;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:35,代码来源:GameFbProducts.class.php

示例9: getAllLeaderBoard

 public static function getAllLeaderBoard($userId = null, $action = null, $page = 0, $pageCount = 10)
 {
     $result = new FunctionResult();
     $result->success = false;
     if ($action == LeaderBoardUtils::$LEADERBOARD_ACTION_ALL) {
         $SQL = "SELECT users.coins as leaderboard_coins,users.lastLoginDate as leaderboard_lastplayed,level.levelName as level_levelname,level.levelNumber as level_levelnumber,level.maxXP as level_maxXP,level.minXP as level_minXP,users.* FROM " . TBL_GAME_USERS . " users," . TBL_GAME_USER_LEVEL . " as level WHERE users.userLevelNumber=level.levelNumber ORDER BY users.coins DESC LIMIT " . DBUtils::mysql_escape($page) . "," . DBUtils::mysql_escape($pageCount);
         $query = mysql_query($SQL, DBUtils::getManualConnection());
         if (empty($query)) {
             $result->success = true;
             $result->result = new stdClass();
             $result->result->list = array();
             $result->result->page = $page;
             $result->result->pageCount = $pageCount;
         } else {
             $list = array();
             $userAdded = false;
             while ($db_field = mysql_fetch_assoc($query)) {
                 $user = GameUsers::createFromSQLWithLeaderboard($db_field);
                 if (!empty($user)) {
                     $userId_ = $user->getUserId();
                     if (!empty($userId_)) {
                         array_push($list, $user);
                     }
                     if ($userId_ == $userId) {
                         $userAdded = true;
                     }
                 }
             }
             if (!$userAdded) {
                 $user = LeaderBoardUtils::getUserAllBoard($userId);
                 if (!empty($user)) {
                     array_push($list, $user);
                 }
             }
             $result->success = true;
             $result->result = new stdClass();
             $result->result->list = $list;
             $result->result->page = $page;
             $result->result->pageCount = $pageCount;
         }
     } else {
         $result->result = "Action is unknown";
     }
     return $result;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:45,代码来源:LeaderBoardFunctions.php


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