本文整理汇总了PHP中Module::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::query方法的具体用法?PHP Module::query怎么用?PHP Module::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateOverlay
public function updateOverlay($overlayId, $gameId, $name, $mediaId, $topLeftLat, $topLeftLong, $topRightLat, $topRightLong, $bottomLeftLat, $bottomLeftLong, $editorId, $editorToken)
{
if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
return new returnData(6, NULL, "Failed Authentication");
}
$newName = addslashes($newName);
Module::query("UPDATE overlays SET game_id = {$gameId}, name = '{$name}', media_id = {$mediaId}, top_left_latitude = {$topLeftLat}, top_left_longitude = {$topLeftLong}, top_right_latitude = {$topRightLat}, top_right_longitude = {$topRightLong}, bottom_left_latitude = {$bottomLeftLat}, bottom_left_longitude = {$bottomLeftLong} WHERE overlay_id = {$overlayId};");
return new returnData(0);
}
示例2: 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;
}
示例3: deleteWebPage
public static function deleteWebPage($gameId, $webPageId)
{
Locations::deleteLocationsForObject($gameId, 'WebPage', $webPageId);
Requirements::deleteRequirementsForRequirementObject($gameId, 'WebPage', $webPageId);
PlayerStateChanges::deletePlayerStateChangesThatRefrenceObject($gameId, 'WebPage', $webPageId);
$query = "DELETE FROM web_pages WHERE game_id = '{$gameId}' AND web_page_id = {$webPageId}";
$rsResult = Module::query($query);
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error");
}
if (mysql_affected_rows()) {
return new returnData(0, TRUE);
} else {
return new returnData(0, FALSE);
}
}
示例4: swapSortIndex
public function swapSortIndex($gameId, $a, $b, $editorId, $editorToken)
{
if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
return new returnData(6, NULL, "Failed Authentication");
}
$result = Module::query("SELECT * FROM quests WHERE game_id = {$gameId} AND (quest_id = '{$a}' OR quest_id = '{$b}')");
$quests = array();
while ($quest = mysql_fetch_object($result)) {
$quests[$quest->quest_id] = $quest;
}
Module::query("UPDATE quests SET sort_index = '{$quests[$a]->sort_index}' WHERE game_id = {$gameId} AND quest_id = '{$b}'");
Module::query("UPDATE quests SET sort_index = '{$quests[$b]->sort_index}' WHERE game_id = {$gameId} AND quest_id = '{$a}'");
return new returnData(0);
}
示例5: fireOffWebHook
protected function fireOffWebHook($playerId, $gameId, $webHookId)
{
Module::appendLog($playerId, $gameId, "SEND_WEBHOOK", $webHookId);
$query = "SELECT * FROM web_hooks WHERE web_hook_id = '{$webHookId}' LIMIT 1";
$result = Module::query($query);
$webHook = mysql_fetch_object($result);
$name = str_replace(" ", "", $webHook->name);
$name = str_replace("{playerId}", $playerId, $webHook->name);
$url = $webHook->url . "?hook=" . $name . "&wid=" . $webHook->web_hook_id . "&gameid=" . $gameId . "&playerid=" . $playerId;
@file_get_contents($url);
}
示例6: getSpawnablesForGame
public static function getSpawnablesForGame($gameId)
{
$query = "SELECT * FROM spawnables WHERE game_id = {$gameId} AND active = 1";
$result = Module::query($query);
$spawnables = array();
while ($obj = mysql_fetch_object($result)) {
$spawnables[] = $obj;
}
return new returnData(0, $spawnables);
}
示例7: getDetailedPlayerItems
public static function getDetailedPlayerItems($playerId, $gameId)
{
/* OTHER ITEMS */
$query = "SELECT DISTINCT i.item_id, i.name, i.description, i.max_qty_in_inventory, i.weight, i.type, i.url, pi.qty, m.file_path as media_url, m.game_id as media_game_id, im.file_path as icon_url, im.game_id as icon_game_id FROM (SELECT * FROM player_items WHERE game_id={$gameId} AND player_id = {$playerId}) as pi LEFT JOIN (SELECT * FROM items WHERE game_id = {$gameId}) as i ON pi.item_id = i.item_id LEFT JOIN media as m ON i.media_id = m.media_id LEFT JOIN media as im ON i.icon_media_id = im.media_id WHERE i.type != 'ATTRIB' GROUP BY i.item_id";
$result = Module::query($query);
$contents = array();
while ($content = mysql_fetch_object($result)) {
if ($content->media_url) {
$content->media_url = Config::gamedataWWWPath . '/' . $content->media_url;
$content->media_thumb_url = substr($content->media_url, 0, strrpos($content->media_url, '.')) . '_128' . substr($content->media_url, strrpos($content->media_url, '.'));
}
if ($content->icon_url) {
$content->icon_url = Config::gamedataWWWPath . '/' . $content->icon_url;
$content->icon_thumb_url = substr($content - icon_url, 0, strrpos($content - icon_url, '.')) . '_128' . substr($content - icon_url, strrpos($content - icon_url, '.'));
}
$content->tags = Items::getItemTags($content->item_id)->data;
$contents[] = $content;
}
return $contents;
}
示例8: uploadPlayerMediaFromJSON
public function uploadPlayerMediaFromJSON($glob)
{
//WHY DOESNT THIS HAPPEN VIA THE FRAMEWORK?!
$data = file_get_contents("php://input");
$glob = json_decode($data);
$playerId = $glob->playerId;
$media = $glob->media;
$media->path = "player";
if (!is_numeric($playerId)) {
return new returnData(1, NULL, "JSON package has no numeric member \"playerId\"");
}
$media = Media::createMediaFromJSON($media)->data;
Module::query("UPDATE players SET media_id = '{$media->media_id}' WHERE player_id = '{$playerId}'");
return new returnData(0, $media);
}
示例9: giveItemToWorld
protected function giveItemToWorld($gameId, $intItemID, $floatLat, $floatLong, $intQty = 1)
{
//Find any items on the map nearby
$clumpingRangeInMeters = 10;
$query = "SELECT *,((ACOS(SIN({$floatLat} * PI() / 180) * SIN(latitude * PI() / 180) + \n COS({$floatLat} * PI() / 180) * COS(latitude * PI() / 180) * \n COS(({$floatLong} - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) * 1609.344\n AS `distance`, location_id \n FROM locations \n WHERE type = 'item' AND type_id = '{$intItemID}' AND game_id = '{$gameId}'\n HAVING distance<= {$clumpingRangeInMeters}\n ORDER BY distance ASC";
$result = Module::query($query);
if ($closestLocationWithinClumpingRange = @mysql_fetch_object($result)) {
//We have a match
$query = "UPDATE locations\n SET item_qty = item_qty + {$intQty}\n WHERE location_id = {$closestLocationWithinClumpingRange->location_id} AND game_id = '{$gameId}'";
Module::query($query);
} else {
$itemName = $this->getItemName($gameId, $intItemID);
$error = 100;
//Use 100 meters
$icon_media_id = $this->getItemIconMediaId($gameId, $intItemID);
//Set the map icon = the item's icon
$query = "INSERT INTO locations (game_id, name, type, type_id, icon_media_id, latitude, longitude, error, item_qty)\n VALUES ('{$gameId}', '{$itemName}','Item','{$intItemID}', '{$icon_media_id}', '{$floatLat}','{$floatLong}', '{$error}','{$intQty}')";
Module::query($query);
$newId = mysql_insert_id();
//Create a coresponding QR Code
QRCodes::createQRCode($gameId, "Location", $newId, '');
}
}
示例10: deleteContent
public static function deleteContent($gameId, $intContentID, $editorId, $editorToken)
{
if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
return new returnData(6, NULL, "Failed Authentication");
}
//Lookup the object
$query = "SELECT content_type,content_id FROM folder_contents WHERE object_content_id = {$intContentID} AND game_id = '{$gameId}' LIMIT 1";
$contentQueryResult = Module::query($query);
$content = @mysql_fetch_object($contentQueryResult);
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error");
}
Spawnables::deleteSpawnablesOfObject($gameId, $content->content_type, $content->content_id, $editorId, $editorToken);
//Delete the content record
$query = "DELETE FROM folder_contents WHERE object_content_id = {$intContentID} AND game_id = '{$gameId}'";
Module::query($query);
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error");
}
//Delete the object
if ($content->content_type == "Node") {
Nodes::deleteNode($gameId, $content->content_id, $editorId, $editorToken);
} else {
if ($content->content_type == "Item") {
Items::deleteItem($gameId, $content->content_id, $editorId, $editorToken);
} else {
if ($content->content_type == "Npc") {
Npcs::deleteNpc($gameId, $content->content_id, $editorId, $editorToken);
} else {
if ($content->content_type == "WebPage") {
WebPages::deleteWebPage($gameId, $content->content_id, $editorId, $editorToken);
} else {
if ($content->content_type == "AugBubble") {
AugBubbles::deleteAugBubble($gameId, $content->content_id, $editorId, $editorToken);
} else {
if ($content->content_type == "PlayerNote") {
Notes::deleteNote($content->content_id, $editorId, $editorToken);
}
}
}
}
}
}
if (mysql_affected_rows()) {
return new returnData(0);
} else {
return new returnData(2, 'invalid folder id');
}
}
示例11: getUnfiredWebhooks
protected function getUnfiredWebhooks($playerId, $gameId)
{
//Get all webhooks for game
$query = "SELECT * FROM web_hooks WHERE game_id = '{$gameId}' AND incoming = 0";
$result = Module::query($query);
$gameWebhooks = array();
while ($gameWebhook = mysql_fetch_object($result)) {
$gameWebhooks[] = $gameWebhook;
}
//Get all webhooks fired by player
$query = "SELECT * FROM player_log WHERE player_id = {$playerId} AND game_id = {$gameId} AND event_type = 'SEND_WEBHOOK' AND deleted = 0;";
$result = Module::query($query);
$playerFiredWebhooks = array();
while ($playerFiredWebhook = mysql_fetch_object($result)) {
$playerFiredWebhooks[] = $playerFiredWebhook;
}
//Cross reference lists to remove already-fired webhooks
$unfiredWebhooks = array();
foreach ($gameWebhooks as $gameWebhook) {
$webhookAlreadyFired = false;
foreach ($playerFiredWebhooks as $playerFiredWebhook) {
if ($gameWebhook->web_hook_id == $playerFiredWebhook->event_detail_1) {
$webhookAlreadyFired = true;
}
}
if (!$webhookAlreadyFired) {
$unfiredWebhooks[] = $gameWebhook;
}
}
return $unfiredWebhooks;
}
示例12: emailUserName
public function emailUserName($strEmail)
{
//set the editor record to this pw
$query = "SELECT * FROM editors\tWHERE email = '{$strEmail}'";
$result = Module::query($query);
if (mysql_error()) {
return new returnData(3, NULL, 'SQL Error' . mysql_error());
}
if (!($editor = mysql_fetch_array($result))) {
return new returnData(4, NULL, "Email is not an editor");
}
$subject = "Recover ARIS Login Information";
$body = "Your ARIS username is: {$editor['name']}";
if (Module::sendEmail($strEmail, $subject, $body)) {
return new returnData(0, NULL);
} else {
return new returnData(5, NULL, "Mail could not be sent");
}
}
示例13: deleteConversationWithNode
public function deleteConversationWithNode($gameId, $conversationId, $editorId, $editorToken)
{
if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
return new returnData(6, NULL, "Failed Authentication");
}
$query = "SELECT node_id FROM npc_conversations WHERE game_id = '{$gameId}' AND conversation_id = {$conversationId} LIMIT 1";
$nodeIdRs = Module::query($query);
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error:" . mysql_error() . "while running query:" . $query);
}
$nodeIdObject = @mysql_fetch_object($nodeIdRs);
if (!$nodeIdObject) {
return new returnData(2, NULL, "No such conversation");
}
$nodeId = $nodeIdObject->node_id;
Nodes::deleteNode($gameId, $nodeId);
$query = "DELETE FROM npc_conversations WHERE game_id = '{$gameId}' AND conversation_id = {$conversationId}";
$rsResult = Module::query($query);
if (mysql_error()) {
return new returnData(3, NULL, "SQL Error");
}
if (mysql_affected_rows()) {
return new returnData(0);
} else {
return new returnData(2, NULL, 'invalid conversation id');
}
}
示例14: lookupActionTypeOptionsFromSQL
private function lookupActionTypeOptionsFromSQL()
{
$query = "SHOW COLUMNS FROM player_state_changes LIKE 'action'";
$result = Module::query($query);
$row = mysql_fetch_array($result, MYSQL_NUM);
$regex = "/'(.*?)'/";
preg_match_all($regex, $row[1], $enum_array);
$enum_fields = $enum_array[1];
return $enum_fields;
}
示例15: playerLikedAPI
private static function playerLikedAPI($playerId, $noteId)
{
$query = "SELECT COUNT(*) as liked FROM note_likes WHERE player_id = '{$playerId}' AND note_id = '{$noteId}' LIMIT 1";
$result = Module::query($query);
$liked = mysql_fetch_object($result);
return $liked->liked;
}