本文整理汇总了PHP中Module::queryArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::queryArray方法的具体用法?PHP Module::queryArray怎么用?PHP Module::queryArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::queryArray方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuestsForPlayer
public function getQuestsForPlayer($gameId, $playerId)
{
$quests = Module::queryArray("SELECT * FROM quests WHERE game_id = {$gameId} ORDER BY sort_index");
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error");
}
$activeQuests = array();
$completedQuests = array();
for ($i = 0; $i < count($quests); $i++) {
$quest = $quests[$i];
$display = Module::objectMeetsRequirements($gameId, $playerId, "QuestDisplay", $quest->quest_id);
$complete = Module::playerHasLog($gameId, $playerId, Module::kLOG_COMPLETE_QUEST, $quest->quest_id);
if ($display && !$complete) {
$activeQuests[] = $quest;
}
if ($display && $complete) {
$completedQuests[] = $quest;
}
}
$return = new stdClass();
$return->totalQuests = count($quests);
$return->active = $activeQuests;
$return->completed = $completedQuests;
return new returnData(0, $return);
}
示例2: getFullItems
public static function getFullItems($gameId)
{
$items = Module::queryArray("SELECT * FROM items WHERE game_id = '{$gameId}';");
$tags = Module::queryArray("SELECT ot.tag_id, ot.object_id, got.media_id, got.tag FROM (SELECT * FROM object_tags WHERE object_type = 'ITEM') as ot LEFT JOIN (SELECT * FROM game_object_tags WHERE game_id = '{$gameId}' AND use_for_sort = '1') as got ON ot.tag_id = got.tag_id;");
for ($i = 0; $i < count($items); $i++) {
$items[$i]->tags = array();
for ($t = 0; $t < count($tags); $t++) {
if ($tags[$t]->object_id == $items[$i]->item_id && $tags[$t]->tag != null) {
$items[$i]->tags[] = $tags[$t];
}
}
}
return new returnData(0, $items);
}
示例3: migrateDB
public static function migrateDB()
{
$migrations = array();
if ($migrationsDir = opendir(Config::migrationsDir)) {
while ($migration = readdir($migrationsDir)) {
if (preg_match('/^[0..9]+\\.sql$/', $migration)) {
$migrations[intval(substr($migration, 0, -4))] = $migration;
}
}
}
$migrated = array();
if (Module::queryObject("SHOW TABLES LIKE 'aris_migrations'")) {
$knownVersions = Module::queryArray("SELECT * FROM aris_migrations");
foreach ($knownVersions as $version) {
if (!$migrated[intval($version->version_major)]) {
$migrated[intval($version->version_major)] = array();
}
$migrated[intval($version->version_major)][intval($version->version_minor)] = $version->timestamp;
}
} else {
//The one migration/construction to be done outside the .sql files
Module::query("CREATE TABLE aris_migrations ( version_major int(32) unsigned NOT NULL, version_minor int(32) unsigned NOT NULL, timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (version_major,version_minor))");
}
foreach ($migrations as $major => $file) {
if ($migrated[$major + 1]) {
continue;
}
$file_handle = fopen(Config::migrationsDir . "/" . $file, "r");
$minor = 0;
while (!feof($file_handle)) {
//Funny way to continue to read from the file until it either ends, or reaches a semicolon
$query = "";
while (!feof($file_handle) && strpos($query .= fgets($file_handle), ';') === FALSE) {
}
if (!$migrated[$major][$minor]) {
mysql_query($query);
if (mysql_error()) {
$error = "Error upgrading database to version " . $major . "." . $minor . ". Error was:\n" . mysql_error() . "\n in query:\n" . $query;
Module::serverErrorLog($error);
echo $error;
return $error;
}
Module::query("INSERT INTO aris_migrations (version_major, version_minor) VALUES ('" . $major . "','" . $minor . "')");
}
$minor++;
}
fclose($file_handle);
}
return 0;
}
示例4: getOverlaysForPlayer
public function getOverlaysForPlayer($gameId, $playerId)
{
$overlays = Module::queryArray("SELECT * FROM overlays WHERE game_id = {$gameId};");
$overlayIds = array();
for ($i = 0; $i < count($overlays); $i++) {
$overlay = $overlays[$i];
$display = Module::objectMeetsRequirements($gameId, $playerId, "CustomMap", $overlay->overlay_id);
if ($display) {
$overlayObj = new stdClass();
$overlayObj->overlay_id = $overlay->overlay_id;
$overlayIds[] = $overlayObj;
}
}
return new returnData(0, $overlayIds);
}
示例5: topPlayersWithMostLikedNotes
public function topPlayersWithMostLikedNotes($gameId, $startFlag = "0000-00-00 00:00:00", $endFlag = "9999-99-99 12:59:59")
{
$notes = Module::queryArray("SELECT note_id, owner_id FROM notes WHERE game_id = '{$gameId}' AND created > '{$startFlag}' AND created < '{$endFlag}'");
$playerLikes = array();
for ($i = 0; $i < count($notes); $i++) {
if (!$playerLikes[$notes[$i]->owner_id]) {
$playerLikes[$notes[$i]->owner_id] = 0;
}
if (Module::queryObject("SELECT player_id FROM note_likes WHERE note_id = '{$notes[$i]->note_id}' LIMIT 1")) {
$playerLikes[$notes[$i]->owner_id]++;
}
}
$playerLikeObjects = array();
foreach ($playerLikes as $pidkey => $countval) {
$plo = new stdClass();
$plo->player_id = $pidkey;
$plo->liked_notes = $countval;
$plo->display_name = Module::queryObject("SELECT display_name FROM players WHERE player_id = '{$pidkey}'")->display_name;
$playerLikeObjects[] = $plo;
}
return $playerLikeObjects;
}
示例6: getGameTags
public function getGameTags($gameId)
{
$tags = Module::queryArray("SELECT tag_id, tag, player_created, media_id from game_tags WHERE game_id = '{$gameId}'");
return new returnData(0, $tags);
}
示例7: getPackagedRequirementsForGameForTypeForId
private function getPackagedRequirementsForGameForTypeForId($gameId, $type, $id)
{
$pack = new stdClass();
$pack->type = $type;
$pack->type_id = $id;
$pack->and_reqs = Module::queryArray("SELECT * FROM requirements WHERE game_id = '{$gameId}' AND content_type = '{$type}' AND content_id = '{$id}' AND boolean_operator = 'AND'");
$pack->or_reqs = Module::queryArray("SELECT * FROM requirements WHERE game_id = '{$gameId}' AND content_type = '{$type}' AND content_id = '{$id}' AND boolean_operator = 'OR'");
return $pack;
}
示例8: getPlayerArrayDataBP
private static function getPlayerArrayDataBP($gameId, $playerArray, $getItems = true, $getAttributes = true, $getNotes = true)
{
//preload data into memory for quick re-use
$mediaA = Media::getMedia($gameId)->data;
$mediaMap = array();
$numMedia = count($mediaA);
for ($i = 0; $i < $numMedia; $i++) {
$mediaMap[$mediaA[$i]->media_id] = $mediaA[$i];
}
if ($getItems) {
$itemsMap = array();
$itemsA = Module::queryArray("SELECT * FROM items WHERE game_id = '{$gameId}' AND (is_attribute = '0' OR is_attribute = '')");
$numItems = count($itemsA);
for ($i = 0; $i < $numItems; $i++) {
$itemsA[$i]->media_url = $mediaMap[$itemsA[$i]->media_id]->url;
$itemsA[$i]->media_thumb_url = $mediaMap[$itemsA[$i]->media_id]->thumb_url;
$itemsA[$i]->icon_url = $mediaMap[$itemsA[$i]->icon_media_id]->url;
$itemsA[$i]->icon_thumb_url = $mediaMap[$itemsA[$i]->icon_media_id]->thumb_url;
$itemsMap[$itemsA[$i]->item_id] = $itemsA[$i];
}
}
if ($getAttributes) {
$attributesMap = array();
$attributesA = Module::queryArray("SELECT * FROM items WHERE game_id = '{$gameId}' AND is_attribute = '1'");
$numAttributes = count($attributesA);
for ($i = 0; $i < $numAttributes; $i++) {
$attributesA[$i]->media_url = $mediaMap[$attributesA[$i]->media_id]->url;
$attributesA[$i]->media_thumb_url = $mediaMap[$attributesA[$i]->media_id]->thumb_url;
$attributesA[$i]->icon_url = $mediaMap[$attributesA[$i]->icon_media_id]->url;
$attributesA[$i]->icon_thumb_url = $mediaMap[$attributesA[$i]->icon_media_id]->thumb_url;
$attributesMap[$attributesA[$i]->media_id] = $attributesA[$i];
}
}
if ($getNotes) {
$gameTagsMap = array();
$gameTagsA = Module::queryArray("SELECT * FROM game_tags WHERE game_id = '{$gameId}'");
$numGameTags = count($gameTagsA);
for ($i = 0; $i < $numGameTags; $i++) {
$gameTagsMap[$gameTagsA[$i]->tag_id] = $gameTagsA[$i];
}
}
$backpacks = array();
$numPlayers = count($playerArray);
for ($i = 0; $i < $numPlayers; $i++) {
$backpack = new stdClass();
$backpack->owner = Module::queryObject("SELECT player_id, user_name, display_name, group_name, media_id FROM players WHERE player_id = '{$playerArray[$i]}'");
if (!$backpack->owner) {
continue;
}
$playerPic = Media::getMediaObject('player', $backpack->owner->media_id)->data;
$backpack->owner->player_pic_url = $playerPic->url;
$backpack->owner->player_pic_thumb_url = $playerPic->thumb_url;
$media->thumb_file_path = substr($media->file_path, 0, strrpos($media->file_path, '.')) . '_128' . substr($media->file_path, strrpos($media->file_path, '.'));
$media->url_path = Config::gamedataWWWPath . "/";
if ($getItems || $getAttributes) {
if ($getItems) {
$backpack->items = array();
}
if ($getAttributes) {
$backpack->attributes = array();
}
$playerItemData = Module::queryArray("SELECT item_id, qty FROM player_items WHERE game_id = '{$gameId}' AND player_id = '{$playerArray[$i]}'");
$numItems = count($playerItemData);
for ($j = 0; $j < $numItems; $j++) {
if ($getItems && isset($itemsMap[$playerItemData[$j]->item_id])) {
$item = clone $itemsMap[$playerItemData[$j]->item_id];
$item->qty = $playerItemData[$j]->qty;
$backpack->items[] = $item;
} else {
if ($getAttributes && isset($attributesMap[$playerItemData[$j]->item_id])) {
$attribute = clone $attributesMap[$playerItemData[$j]->item_id];
$attribute->qty = $playerItemData[$j]->qty;
$backpack->attributes[] = $attribute;
}
}
}
}
if ($getNotes) {
$rawNotes = Module::query("SELECT * FROM notes WHERE owner_id = '{$playerArray[$i]}' AND game_id = '{$gameId}' AND parent_note_id = 0 ORDER BY sort_index ASC");
$backpack->notes = array();
while ($note = mysql_fetch_object($rawNotes)) {
$note->username = $backpack->owner->user_name;
if ($backpack->owner->display_name && $backpack->owner->display_name != "") {
$note->username = $backpack->owner->display_name;
}
$rawContent = Module::query("SELECT * FROM note_content WHERE note_id = '{$note->note_id}'");
$note->contents = array();
while ($content = mysql_fetch_object($rawContent)) {
$content->media_url = $mediaMap[$content->media_id]->url;
$content->media_thumb_url = $mediaMap[$content->media_id]->thumb_url;
$note->contents[] = $content;
}
$note->likes = Notes::getNoteLikes($note->note_id);
$note->player_liked = Notes::playerLiked($playerId, $note->note_id);
$result = Module::query("SELECT * FROM note_tags WHERE note_id = '{$note->note_id}'");
$note->tags = array();
while ($tag = mysql_fetch_object($result)) {
$note->tags[] = $gameTagsMap[$tag->tag_id];
}
$note->dropped = 0;
//.........这里部分代码省略.........
示例9: getEditorsWithEmail
public function getEditorsWithEmail($email)
{
$eArray = Module::queryArray("SELECT editor_id, email FROM editors WHERE email LIKE '" . $email . "'");
return new returnData(0, $eArray);
}
示例10: getPlayerLogs
public function getPlayerLogs($glob)
{
ini_set('display_errors', 1);
error_reporting(E_ALL);
//Grrr amfphp should take care of this...
$data = file_get_contents("php://input");
$glob = json_decode($data);
$reqOutputFormat = $glob->output_format;
$reqOutputToFile = $glob->output_to_file;
$reqOutputFilename = $glob->output_filename;
$reqGameId = $glob->game_id;
$reqEditorId = $glob->editor_id;
$reqEditorToken = $glob->editor_token;
$reqGroup = $glob->groupname;
$reqPlayers = $glob->players;
$reqPlayer = $glob->player;
$reqStartDate = $glob->start_date;
$reqEndDate = $glob->end_date;
$reqGetExpired = $glob->get_expired;
$reqVerbose = $glob->verbose;
$iknowwhatimdoing = $glob->i_know_what_im_doing == "yes";
//minimal level of "security" to prevent massive data requests
if ($iknowwhatimdoing) {
set_time_limit(0);
ignore_user_abort(1);
}
//validation
$expectsNotice = 'Expects JSON argument of minimal form: {"output_format":"json","game_id":1,"editor_id":1,"editor_token":"abc123"}';
if (!is_string($reqOutputFormat)) {
$reqOutputFormat = "json";
} else {
$reqOutputFormat = strToLower($reqOutputFormat);
}
if ($reqOutputFormat != "json" && $reqOutputFormat != "csv" && $reqOutputFormat != "xml") {
return new returnData(1, NULL, "Error- Invalid output format (" . $reqOutputFormat . ")\n" . $expectsNotice);
}
if (is_numeric($reqOutputToFile)) {
$reqOutputToFile = intval($reqOutputToFile);
} else {
$reqOutputToFile = 0;
}
if (!is_string($reqOutputFilename)) {
$reqOutputFilename = $reqOutputToFile ? "mostrecentlogrequest" : "tmpmostrecentlogrequest";
}
if (is_numeric($reqGameId)) {
$reqGameId = intval($reqGameId);
} else {
return new returnData(1, NULL, "Error- Empty Game (" . $reqGameId . ")\n" . $expectsNotice);
}
if (is_numeric($reqEditorId)) {
$reqEditorId = intval($reqEditorId);
} else {
return new returnData(1, NULL, "Error- Empty Editor (" . $reqEditorId . ")\n" . $expectsNotice);
}
if (!is_string($reqEditorToken)) {
return new returnData(1, NULL, "Error- Invalid EditorToken (" . $reqEditorToken . ")\n" . $expectsNotice);
}
if (!Module::authenticateGameEditor($reqGameId, $reqEditorId, $reqEditorToken, "read_write")) {
return new returnData(6, NULL, "Failed Authentication");
}
$filterMode = "none";
if (is_string($reqGroup)) {
$filterMode = "group";
}
if (is_array($reqPlayers)) {
$filterMode = "players";
}
if (is_numeric($reqPlayer)) {
$filterMode = "player";
}
if (!preg_match("/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/", $reqStartDate)) {
$reqStartDate = "0000-00-00 00:00:00";
}
if (!preg_match("/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/", $reqEndDate)) {
$reqEndDate = "9999-00-00 00:00:00";
}
if (!$iknowwhatimdoing && floor(abs(strtotime($reqEndDate) - strtotime($reqStartDate)) / (60 * 60 * 24 * 31)) > 0) {
return new returnData(1, NULL, "Please don't ask for more than a month of data at a time!");
}
if (!is_numeric($reqGetExpired)) {
$reqGetExpired = 0;
} else {
if (intval($reqGetExpired) > 0) {
$reqGetExpired = 1;
}
}
if (!is_numeric($reqVerbose)) {
$reqVerbose = 0;
} else {
if (intval($reqVerbose) > 0) {
$reqVerbose = 1;
}
}
$playerLogs = array();
if ($filterMode == "group") {
$p = Module::queryArray("SELECT player_id, display_name, media_id, group_name from players WHERE group_name = '{$reqGroup}'");
for ($i = 0; $i < count($p); $i++) {
$log = new stdClass();
$log->player = $p[$i];
if ($log->player->display_name == "") {
//.........这里部分代码省略.........
示例11: pruneNoteContentFromGame
public function pruneNoteContentFromGame($gameId, $surrogate, $editorId, $editorToken)
{
if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
return new returnData(6, NULL, "Failed Authentication");
}
$unused_content = array();
$noteContent = Module::queryArray("SELECT * FROM note_content WHERE game_id = '{$gameId}'");
for ($i = 0; $i < count($noteContent); $i++) {
if (!Module::queryObject("SELECT * FROM notes WHERE game_id = '{$gameId}' AND note_id = '{$noteContent[$i]->note_id}'")) {
$unused_content[] = $noteContent[$i]->content_id;
}
}
if ($surrogate) {
for ($i = 0; $i < count($unused_content); $i++) {
Module::query("UPDATE note_content SET game_id = '{$surrogate}' WHERE game_id = '{$gameId}' AND content_id = '{$unused_content[$i]}'");
}
} else {
for ($i = 0; $i < count($unused_content); $i++) {
Module::query("DELETE FROM note_content WHERE game_id = '{$gameId}' AND content_id = '{$unused_content[$i]}'");
}
}
return $unused_content;
}
示例12: getLocationsForPlayer
public function getLocationsForPlayer($gameId, $intPlayerId, $lat = 0, $lon = 0)
{
$arrayLocations = array();
//Gets all non-spawned locations
$query = "SELECT game_locations.*, gamefountains.fountain_id, gamefountains.spawn_probability, gamefountains.spawn_rate, gamefountains.max_amount, gamefountains.last_spawned, gamefountains.active FROM (SELECT * FROM locations WHERE game_id = {$gameId}) AS game_locations LEFT JOIN (SELECT * FROM spawnables WHERE game_id = {$gameId}) AS gamespawns ON game_locations.type = gamespawns.type AND game_locations.type_id = gamespawns.type_id LEFT JOIN (SELECT * FROM fountains WHERE game_id = {$gameId}) AS gamefountains ON game_locations.location_id = gamefountains.location_id WHERE game_locations.latitude != '' AND game_locations.longitude != '' AND (spawnable_id IS NULL OR gamespawns.active = 0)";
$rsLocations = Module::query($query);
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error" . mysql_error());
}
$query = "SELECT full_quick_travel FROM games WHERE game_id = '{$gameId}'";
$fqtresult = Module::query($query);
$fullQuickTravel = mysql_fetch_object($fqtresult)->full_quick_travel == 1 ? true : false;
while ($location = mysql_fetch_object($rsLocations)) {
//If location and object it links to meet requirments, add it to the array
//Does it Exist?
switch ($location->type) {
case 'Item':
$query = "SELECT icon_media_id FROM items WHERE game_id = {$gameId} AND item_id = {$location->type_id} LIMIT 1";
break;
case 'Node':
$query = "SELECT icon_media_id FROM nodes WHERE game_id = {$gameId} AND node_id = {$location->type_id} LIMIT 1";
break;
case 'Npc':
$query = "SELECT icon_media_id FROM npcs WHERE game_id = {$gameId} AND npc_id = {$location->type_id} LIMIT 1";
break;
case 'WebPage':
$query = "SELECT icon_media_id FROM web_pages WHERE web_page_id = {$location->type_id} LIMIT 1";
break;
case 'AugBubble':
$query = "SELECT icon_media_id FROM aug_bubbles WHERE aug_bubble_id = {$location->type_id} LIMIT 1";
break;
case 'PlayerNote':
$query = "SELECT public_to_map FROM notes WHERE note_id = {$location->type_id} LIMIT 1";
break;
}
if ($location->type == 'PlayerNote') {
$rsObject = Module::query($query);
$object = @mysql_fetch_object($rsObject);
if (!$object || $object->public_to_map == 0) {
continue;
}
} else {
$rsObject = Module::query($query);
$object = @mysql_fetch_object($rsObject);
if (!$object) {
continue;
}
}
//Deal with qty (whether empty, or fountain)
if ($location->fountain_id && $location->active) {
$secondsOfSpawning = strtotime("now") - strtotime($location->last_spawned);
while ($secondsOfSpawning > $location->spawn_rate && $location->item_qty < $location->max_amount) {
if (rand(0, 100) < $location->spawn_probability) {
$location->item_qty++;
}
$secondsOfSpawning -= $location->spawn_rate;
$query = "UPDATE fountains SET last_spawned = now() WHERE fountain_id = " . $location->fountain_id;
Module::query($query);
}
if ($location->item_qty >= $location->max_amount) {
$query = "UPDATE fountains SET last_spawned = now() WHERE fountain_id = " . $location->fountain_id;
Module::query($query);
}
$query = "UPDATE locations SET item_qty = " . $location->item_qty . " WHERE game_id = {$gameId} AND location_id = " . $location->location_id;
Module::query($query);
}
if ($location->type == 'Item' && $location->item_qty < 1 && $location->item_qty != -1) {
continue;
}
//Does it meet it's requirements?
if (!$this->objectMeetsRequirements($gameId, $intPlayerId, 'Location', $location->location_id)) {
continue;
}
//Special Case for Notes
if ($location->type == 'PlayerNote') {
$query = "SELECT public_to_map, public_to_notebook, owner_id FROM notes WHERE note_id='{$location->type_id}' LIMIT 1";
$result = Module::query($query);
$note = mysql_fetch_object($result);
//If note doesn't exist, or if it is neither public nor owned by the owner, skip it.
if (!$note || !($note->public_to_map || $note->owner_id == $intPlayerId)) {
continue;
}
if ($note->public_to_notebook || $note->owner_id == $intPlayerId) {
$location->allow_quick_travel = 1;
}
}
//If location's icon is not defined, use the object's icon
if (!$location->icon_media_id) {
$objectsIconMediaId = $object->icon_media_id;
$location->icon_media_id = $objectsIconMediaId;
}
$location->delete_when_viewed = 0;
if ($fullQuickTravel) {
$location->allow_quick_travel = true;
}
//Add it
$arrayLocations[] = $location;
}
//Get all spawned locations (needs separate calculations, as requirements are not associated with each location)
$spawnables = Module::queryArray("SELECT * FROM spawnables WHERE game_id = " . $gameId . " AND active = 1");
//.........这里部分代码省略.........