* cache $db->hasTable and $db->hasColumn functions

* changed tableExist and fieldExist to $db->hasTable(table) +
$db->hasColumn(table, column)
* new configurable: database_log - can log database queries and show in
website source when logged as super admin
* removed debug_level configurable, enabled by default when logged on
super admin
* added OTS_Account:getCountry()
* added posibility to load OTS_Player partially, and without skills
* (internal) changed depracated $ots->createObject() functions with
their OTS_ equivalents
* (internal) removed unused code
This commit is contained in:
slawkens1
2018-01-06 05:44:33 +01:00
parent 31537687c1
commit 1025fad0e6
65 changed files with 446 additions and 417 deletions

View File

@@ -1,8 +1,8 @@
<?php
if(!fieldExist('ordering', TABLE_PREFIX . 'hooks'))
if(!$db->hasColumn(TABLE_PREFIX . 'hooks', 'ordering'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `ordering` INT(11) NOT NULL DEFAULT 0 AFTER `file`;");
if(!tableExist(TABLE_PREFIX . 'admin_menu'))
if(!$db->hasTable(TABLE_PREFIX . 'admin_menu'))
$db->query("
CREATE TABLE `myaac_admin_menu`
(

View File

@@ -1,7 +1,7 @@
<?php
// add new item_id field for runes
if(!fieldExist('item_id', TABLE_PREFIX . 'spells'))
if(!$db->hasColumn(TABLE_PREFIX . 'spells', 'item_id'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` ADD `item_id` INT(11) NOT NULL DEFAULT 0 AFTER `conjure_count`;");
// change unique index from spell to name
@@ -12,7 +12,7 @@ $db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` ADD UNIQUE INDEX (`name`);"
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` MODIFY `type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - conjure, 3 - rune';");
// new items table
if(!tableExist(TABLE_PREFIX . 'items'))
if(!$db->hasTable(TABLE_PREFIX . 'items'))
$db->query("
CREATE TABLE `" . TABLE_PREFIX . "items`
(
@@ -25,7 +25,7 @@ CREATE TABLE `" . TABLE_PREFIX . "items`
) ENGINE = MyISAM;");
// new weapons table
if(!tableExist(TABLE_PREFIX . 'weapons'))
if(!$db->hasTable(TABLE_PREFIX . 'weapons'))
$db->query("
CREATE TABLE `" . TABLE_PREFIX . "weapons`
(

View File

@@ -1,4 +1,4 @@
<?php
if(fieldExist('spell', TABLE_PREFIX . 'spells'))
if($db->hasColumn(TABLE_PREFIX . 'spells', 'spell'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN `spell`;");
?>

View File

@@ -1,7 +1,7 @@
<?php
// change monsters.file_path field to loot
if(fieldExist('file_path', TABLE_PREFIX . 'monsters')) {
if($db->hasColumn(TABLE_PREFIX . 'monsters', 'file_path')) {
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `file_path` `loot` VARCHAR(5000);");
}
@@ -12,7 +12,7 @@ $db->query("UPDATE `" . TABLE_PREFIX . "monsters` SET `loot` = '';");
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` DROP COLUMN `gfx_name`;");
// rename hide_creature to hidden
if(fieldExist('hide_creature', TABLE_PREFIX . 'monsters')) {
if($db->hasColumn(TABLE_PREFIX . 'monsters', 'hide_creature')) {
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `hide_creature` `hidden` TINYINT(1) NOT NULL DEFAULT 0;");
}
?>

View File

@@ -1,11 +1,11 @@
<?php
// add new forum.guild and forum.access fields
if(!fieldExist('guild', TABLE_PREFIX . 'forum_boards')) {
if(!$db->hasColumn(TABLE_PREFIX . 'forum_boards', 'guild')) {
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `guild` TINYINT(1) NOT NULL DEFAULT 0 AFTER `closed`;");
}
if(!fieldExist('access', TABLE_PREFIX . 'forum_boards')) {
if(!$db->hasColumn(TABLE_PREFIX . 'forum_boards', 'access')) {
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `access` TINYINT(1) NOT NULL DEFAULT 0 AFTER `guild`;");
}
?>

View File

@@ -1,6 +1,6 @@
<?php
if(!tableExist('myaac_menu')) {
if(!$db->hasTable('myaac_menu')) {
$db->query("
CREATE TABLE `myaac_menu`
(

View File

@@ -1,4 +1,4 @@
<?php
if(!fieldExist('id', TABLE_PREFIX . 'monsters'))
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'id'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `id` int(11) NOT NULL AUTO_INCREMENT primary key FIRST;");
?>

View File

@@ -1,4 +1,4 @@
<?php
if(fieldExist('cities', TABLE_PREFIX . 'spells'))
if($db->hasColumn(TABLE_PREFIX . 'spells', 'cities'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN cities;");
?>

View File

@@ -1,4 +1,4 @@
<?php
if(!fieldExist('enabled', TABLE_PREFIX . 'hooks'))
if(!$db->hasColumn(TABLE_PREFIX . 'hooks', 'enabled'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `enabled` INT(1) NOT NULL DEFAULT 1;");
?>

View File

@@ -1,4 +1,4 @@
<?php
if(fieldExist('name', TABLE_PREFIX . 'screenshots'))
if($db->hasColumn(TABLE_PREFIX . 'screenshots', 'name'))
$db->query("ALTER TABLE `" . TABLE_PREFIX . "screenshots` DROP `name`;");
?>

View File

@@ -1,5 +1,5 @@
<?php
if(tableExist(TABLE_PREFIX . 'forum_sections'))
if($db->hasTable(TABLE_PREFIX . 'forum_sections'))
$db->query('RENAME TABLE `' . TABLE_PREFIX . 'forum_sections` TO `' . TABLE_PREFIX . 'forum_boards`;');
$query = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'forum_boards` WHERE `ordering` > 0;');