本文整理匯總了PHP中SmrMySqlDatabase::escapeObject方法的典型用法代碼示例。如果您正苦於以下問題:PHP SmrMySqlDatabase::escapeObject方法的具體用法?PHP SmrMySqlDatabase::escapeObject怎麽用?PHP SmrMySqlDatabase::escapeObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SmrMySqlDatabase
的用法示例。
在下文中一共展示了SmrMySqlDatabase::escapeObject方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: debug
function &findRoutes(&$player)
{
debug('Finding Routes');
$galaxies =& SmrGalaxy::getGameGalaxies($player->getGameID());
$tradeGoods = array(GOOD_NOTHING => false);
$goods =& Globals::getGoods();
foreach ($goods as $goodID => &$good) {
if ($player->meetsAlignmentRestriction($good['AlignRestriction'])) {
$tradeGoods[$goodID] = true;
} else {
$tradeGoods[$goodID] = false;
}
}
unset($good);
$tradeRaces = array();
$races =& Globals::getRaces();
foreach ($races as $raceID => &$race) {
$tradeRaces[$raceID] = false;
}
unset($race);
$tradeRaces[$player->getRaceID()] = true;
$galaxy =& $player->getSector()->getGalaxy();
$maxNumberOfPorts = 2;
$routesForPort = -1;
$numberOfRoutes = 1000;
$maxDistance = 15;
$startSectorID = $galaxy->getStartSector();
$endSectorID = $galaxy->getEndSector();
$db = new SmrMySqlDatabase();
$db->query('SELECT routes FROM route_cache WHERE game_id=' . $db->escapeNumber($player->getGameID()) . ' AND max_ports=' . $db->escapeNumber($maxNumberOfPorts) . ' AND goods_allowed=' . $db->escapeObject($tradeGoods) . ' AND races_allowed=' . $db->escapeObject($tradeRaces) . ' AND start_sector_id=' . $db->escapeNumber($startSectorID) . ' AND end_sector_id=' . $db->escapeNumber($endSectorID) . ' AND routes_for_port=' . $db->escapeNumber($routesForPort) . ' AND max_distance=' . $db->escapeNumber($maxDistance));
if ($db->nextRecord()) {
$routes = unserialize(gzuncompress($db->getField('routes')));
debug('Using Cached Routes: #' . count($routes));
return $routes;
} else {
debug('Generating Routes');
$allSectors = array();
foreach ($galaxies as &$galaxy) {
$allSectors += $galaxy->getSectors();
//Merge arrays
}
unset($galaxy);
$distances =& Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
if ($maxNumberOfPorts == 1) {
$allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
} else {
$allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
}
unset($distances);
$allRoutes =& $allRoutes[RouteGenerator::EXP_ROUTE];
$routesMerged = array();
foreach ($allRoutes as $multi => &$routesByMulti) {
$routesMerged += $routesByMulti;
//Merge arrays
}
unset($routesByMulti);
unset($allSectors);
SmrPort::clearCache();
SmrSector::clearCache();
$db->query('INSERT INTO route_cache ' . '(game_id, max_ports, goods_allowed, races_allowed, start_sector_id, end_sector_id, routes_for_port, max_distance, routes)' . ' VALUES (' . $db->escapeNumber($player->getGameID()) . ', ' . $db->escapeNumber($maxNumberOfPorts) . ', ' . $db->escapeObject($tradeGoods) . ', ' . $db->escapeObject($tradeRaces) . ', ' . $db->escapeNumber($startSectorID) . ', ' . $db->escapeNumber($endSectorID) . ', ' . $db->escapeNumber($routesForPort) . ', ' . $db->escapeNumber($maxDistance) . ', ' . $db->escapeObject($routesMerged, true) . ')');
debug('Found Routes: #' . count($routesMerged));
return $routesMerged;
}
}