summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-02-28 06:37:28 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-02-28 06:37:28 +0000
commitc04ff8e02f01691dc2e325efc523e43f3aebaf95 (patch)
tree8fbdfe90c1bb04b9b8b74500904c09f126430e19
parentad56995bafffeca89c44b07cb4f25da7b36a1a99 (diff)
Change the pattern to identify tables that need prefix substitution to
mirror the drupal pattern of using braces {}.
-rw-r--r--core/controllers/admin_maintenance.php2
-rw-r--r--core/controllers/scaffold.php4
-rw-r--r--core/helpers/access.php12
-rw-r--r--core/helpers/core_installer.php56
-rw-r--r--core/helpers/graphics.php2
-rw-r--r--core/helpers/module.php2
-rw-r--r--core/libraries/MY_Database.php2
-rw-r--r--core/libraries/ORM_MPTT.php22
-rw-r--r--core/tests/Database_Test.php8
-rw-r--r--installer/installer.php6
-rw-r--r--modules/comment/controllers/admin_comments.php2
-rw-r--r--modules/comment/helpers/comment_installer.php6
-rw-r--r--modules/exif/helpers/exif_installer.php6
-rw-r--r--modules/exif/helpers/exif_task.php14
-rw-r--r--modules/notification/helpers/notification_installer.php4
-rw-r--r--modules/search/helpers/search_installer.php6
-rw-r--r--modules/search/helpers/search_task.php14
-rw-r--r--modules/tag/helpers/tag_event.php8
-rw-r--r--modules/tag/helpers/tag_installer.php8
-rw-r--r--modules/user/helpers/user_installer.php12
-rw-r--r--modules/watermark/helpers/watermark_installer.php4
21 files changed, 100 insertions, 100 deletions
diff --git a/core/controllers/admin_maintenance.php b/core/controllers/admin_maintenance.php
index e24cc50b..6f553161 100644
--- a/core/controllers/admin_maintenance.php
+++ b/core/controllers/admin_maintenance.php
@@ -23,7 +23,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
*/
public function index() {
$query = Database::instance()->query(
- "UPDATE `tasks` SET `state` = 'stalled' " .
+ "UPDATE {tasks} SET `state` = 'stalled' " .
"WHERE done = 0 " .
"AND state <> 'stalled' " .
"AND unix_timestamp(now()) - updated > 120");
diff --git a/core/controllers/scaffold.php b/core/controllers/scaffold.php
index 554d576c..cdbe0f95 100644
--- a/core/controllers/scaffold.php
+++ b/core/controllers/scaffold.php
@@ -509,8 +509,8 @@ class Scaffold_Controller extends Template_Controller {
// We now have a clean install with just the packages that we want. Make sure that the
// database is clean too.
$db = Database::instance();
- $db->query("TRUNCATE `[sessions]`");
- $db->query("TRUNCATE `[logs]`");
+ $db->query("TRUNCATE {sessions}");
+ $db->query("TRUNCATE {logs}");
$db->update("users", array("password" => ""), array("id" => 2));
$dbconfig = Kohana::config('database.default');
diff --git a/core/helpers/access.php b/core/helpers/access.php
index a9f48c20..a759fca1 100644
--- a/core/helpers/access.php
+++ b/core/helpers/access.php
@@ -404,8 +404,8 @@ class access_Core {
$db = Database::instance();
$field = "{$perm_name}_{$group->id}";
$cache_table = $perm_name == "view" ? "items" : "access_caches";
- $db->query("ALTER TABLE `[$cache_table]` DROP `$field`");
- $db->query("ALTER TABLE `[access_intents]` DROP `$field`");
+ $db->query("ALTER TABLE {{$cache_table}} DROP `$field`");
+ $db->query("ALTER TABLE {access_intents} DROP `$field`");
ORM::factory("access_intent")->clear_cache();
}
@@ -420,8 +420,8 @@ class access_Core {
$db = Database::instance();
$field = "{$perm_name}_{$group->id}";
$cache_table = $perm_name == "view" ? "items" : "access_caches";
- $db->query("ALTER TABLE `[$cache_table]` ADD `$field` TINYINT(2) NOT NULL DEFAULT 0");
- $db->query("ALTER TABLE `[access_intents]` ADD `$field` BOOLEAN DEFAULT NULL");
+ $db->query("ALTER TABLE {{$cache_table}} ADD `$field` TINYINT(2) NOT NULL DEFAULT 0");
+ $db->query("ALTER TABLE {access_intents} ADD `$field` BOOLEAN DEFAULT NULL");
$db->update("access_intents", array($field => 0), array("item_id" => 1));
ORM::factory("access_intent")->clear_cache();
}
@@ -547,9 +547,9 @@ class access_Core {
->find_all();
foreach ($query as $row) {
$db->query(
- "UPDATE `[access_caches]` SET `$field` = {$row->$field} " .
+ "UPDATE {access_caches} SET `$field` = {$row->$field} " .
"WHERE `item_id` IN " .
- " (SELECT `id` FROM `[items]` " .
+ " (SELECT `id` FROM {items} " .
" WHERE `left` >= $row->left " .
" AND `right` <= $row->right)");
}
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index d3eb3090..83c6907a 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -31,19 +31,19 @@ class core_installer {
}
if ($version == 0) {
- $db->query("CREATE TABLE `[access_caches]` (
+ $db->query("CREATE TABLE {access_caches} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9),
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[access_intents]` (
+ $db->query("CREATE TABLE {access_intents} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9),
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[graphics_rules]` (
+ $db->query("CREATE TABLE {graphics_rules} (
`id` int(9) NOT NULL auto_increment,
`priority` int(9) NOT NULL,
`module_name` varchar(64) NOT NULL,
@@ -53,7 +53,7 @@ class core_installer {
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[items]` (
+ $db->query("CREATE TABLE {items} (
`album_cover_item_id` int(9) default NULL,
`created` int(9) default NULL,
`description` varchar(255) default NULL,
@@ -84,7 +84,7 @@ class core_installer {
KEY `random` (`rand_key` DESC))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[logs]` (
+ $db->query("CREATE TABLE {logs} (
`id` int(9) NOT NULL auto_increment,
`category` varchar(64) default NULL,
`html` varchar(255) default NULL,
@@ -97,7 +97,7 @@ class core_installer {
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[messages]` (
+ $db->query("CREATE TABLE {messages} (
`id` int(9) NOT NULL auto_increment,
`key` varchar(255) default NULL,
`value` varchar(255) default NULL,
@@ -106,7 +106,7 @@ class core_installer {
UNIQUE KEY(`key`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[modules]` (
+ $db->query("CREATE TABLE {modules} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(64) default NULL,
`version` int(9) default NULL,
@@ -114,7 +114,7 @@ class core_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[themes]` (
+ $db->query("CREATE TABLE {themes} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(64) default NULL,
`version` int(9) default NULL,
@@ -122,7 +122,7 @@ class core_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[permissions]` (
+ $db->query("CREATE TABLE {permissions} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(64) default NULL,
`display_name` varchar(64) default NULL,
@@ -130,7 +130,7 @@ class core_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[incoming_translations]` (
+ $db->query("CREATE TABLE {incoming_translations} (
`id` int(9) NOT NULL auto_increment,
`key` char(32) NOT NULL,
`locale` char(10) NOT NULL,
@@ -142,7 +142,7 @@ class core_installer {
KEY `locale_key` (`locale`, `key`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[outgoing_translations]` (
+ $db->query("CREATE TABLE {outgoing_translations} (
`id` int(9) NOT NULL auto_increment,
`key` char(32) NOT NULL,
`locale` char(10) NOT NULL,
@@ -154,14 +154,14 @@ class core_installer {
KEY `locale_key` (`locale`, `key`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[sessions]` (
+ $db->query("CREATE TABLE {sessions} (
`session_id` varchar(127) NOT NULL,
`last_activity` int(10) UNSIGNED NOT NULL,
`data` text NOT NULL,
PRIMARY KEY (`session_id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[tasks]` (
+ $db->query("CREATE TABLE {tasks} (
`callback` varchar(128) default NULL,
`context` text NOT NULL,
`done` boolean default 0,
@@ -176,7 +176,7 @@ class core_installer {
KEY (`owner_id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE `[vars]` (
+ $db->query("CREATE TABLE {vars} (
`id` int(9) NOT NULL auto_increment,
`module_name` varchar(64) NOT NULL,
`name` varchar(64) NOT NULL,
@@ -266,20 +266,20 @@ class core_installer {
static function uninstall() {
$db = Database::instance();
- $db->query("DROP TABLE IF EXISTS `[access_caches]`;");
- $db->query("DROP TABLE IF EXISTS `[access_intents]`;");
- $db->query("DROP TABLE IF EXISTS `[graphics_rules]`;");
- $db->query("DROP TABLE IF EXISTS `[items`;");
- $db->query("DROP TABLE IF EXISTS `[logs]`;");
- $db->query("DROP TABLE IF EXISTS `[messages]`;");
- $db->query("DROP TABLE IF EXISTS `[modules]`;");
- $db->query("DROP TABLE IF EXISTS `[themes]`;");
- $db->query("DROP TABLE IF EXISTS `[incoming_translations]`;");
- $db->query("DROP TABLE IF EXISTS `[outgoing_translations]`;");
- $db->query("DROP TABLE IF EXISTS `[permissions]`;");
- $db->query("DROP TABLE IF EXISTS `[sessions]`;");
- $db->query("DROP TABLE IF EXISTS `[tasks]`;");
- $db->query("DROP TABLE IF EXISTS `[vars]`;");
+ $db->query("DROP TABLE IF EXISTS {access_caches};");
+ $db->query("DROP TABLE IF EXISTS {access_intents};");
+ $db->query("DROP TABLE IF EXISTS {graphics_rules};");
+ $db->query("DROP TABLE IF EXISTS {items`;");
+ $db->query("DROP TABLE IF EXISTS {logs};");
+ $db->query("DROP TABLE IF EXISTS {messages};");
+ $db->query("DROP TABLE IF EXISTS {modules};");
+ $db->query("DROP TABLE IF EXISTS {themes};");
+ $db->query("DROP TABLE IF EXISTS {incoming_translations};");
+ $db->query("DROP TABLE IF EXISTS {outgoing_translations};");
+ $db->query("DROP TABLE IF EXISTS {permissions};");
+ $db->query("DROP TABLE IF EXISTS {sessions};");
+ $db->query("DROP TABLE IF EXISTS {tasks};");
+ $db->query("DROP TABLE IF EXISTS {vars};");
foreach (array("albums", "resizes", "thumbs", "uploads", "modules") as $dir) {
system("/bin/rm -rf " . VARPATH . $dir);
}
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index 5c3480c9..3d0c405d 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -223,7 +223,7 @@ class graphics_Core {
*/
static function find_dirty_images_query() {
return Database::instance()->query(
- "SELECT `id` FROM `[items]` " .
+ "SELECT `id` FROM {items} " .
"WHERE (`thumb_dirty` = 1 AND (`type` <> 'album' OR `album_cover_item_id` IS NOT NULL))" .
" OR (`resize_dirty` = 1 AND `type` = 'photo')");
}
diff --git a/core/helpers/module.php b/core/helpers/module.php
index 1bc8214f..d5dea099 100644
--- a/core/helpers/module.php
+++ b/core/helpers/module.php
@@ -241,7 +241,7 @@ class module_Core {
*/
static function incr_var($module_name, $name, $increment=1) {
Database::instance()->query(
- "UPDATE `[vars]` SET `value` = `value` + $increment " .
+ "UPDATE {vars} SET `value` = `value` + $increment " .
"WHERE `module_name` = '$module_name' " .
"AND `name` = '$name'");
}
diff --git a/core/libraries/MY_Database.php b/core/libraries/MY_Database.php
index 7d6c3ece..be0c2ec3 100644
--- a/core/libraries/MY_Database.php
+++ b/core/libraries/MY_Database.php
@@ -56,6 +56,6 @@ class Database extends Database_Core {
public function add_table_prefixes($sql) {
$prefix = $this->config["table_prefix"];
- return preg_replace("#\[([a-zA-Z0-9_]+)\]#", "{$prefix}$1", $sql);
+ return preg_replace("#{([a-zA-Z0-9_]+)}#", "{$prefix}$1", $sql);
}
} \ No newline at end of file
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php
index c1adb920..7e89bf6f 100644
--- a/core/libraries/ORM_MPTT.php
+++ b/core/libraries/ORM_MPTT.php
@@ -52,9 +52,9 @@ class ORM_MPTT_Core extends ORM {
try {
// Make a hole in the parent for this new item
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `left` = `left` + 2 WHERE `left` >= {$parent->right}");
+ "UPDATE {{$this->table_name}} SET `left` = `left` + 2 WHERE `left` >= {$parent->right}");
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `right` = `right` + 2 WHERE `right` >= {$parent->right}");
+ "UPDATE {{$this->table_name}} SET `right` = `right` + 2 WHERE `right` >= {$parent->right}");
$parent->right += 2;
// Insert this item into the hole
@@ -90,9 +90,9 @@ class ORM_MPTT_Core extends ORM {
$this->lock();
try {
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `left` = `left` - 2 WHERE `left` > {$this->right}");
+ "UPDATE {{$this->table_name}} SET `left` = `left` - 2 WHERE `left` > {$this->right}");
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `right` = `right` - 2 WHERE `right` > {$this->right}");
+ "UPDATE {{$this->table_name}} SET `right` = `right` - 2 WHERE `right` > {$this->right}");
} catch (Exception $e) {
$this->unlock();
throw $e;
@@ -229,21 +229,21 @@ class ORM_MPTT_Core extends ORM {
if ($level_delta) {
// Update the levels for the to-be-moved items
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `level` = `level` + $level_delta" .
+ "UPDATE {{$this->table_name}} SET `level` = `level` + $level_delta" .
" WHERE `left` >= $original_left AND `right` <= $original_right");
}
// Make a hole in the target for the move
$target->db->query(
- "UPDATE `[{$this->table_name}]` SET `left` = `left` + $size_of_hole" .
+ "UPDATE {{$this->table_name}} SET `left` = `left` + $size_of_hole" .
" WHERE `left` >= $target_right");
$target->db->query(
- "UPDATE `[{$this->table_name}]` SET `right` = `right` + $size_of_hole" .
+ "UPDATE {{$this->table_name}} SET `right` = `right` + $size_of_hole" .
" WHERE `right` >= $target_right");
// Change the parent.
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `parent_id` = {$target->id}" .
+ "UPDATE {{$this->table_name}} SET `parent_id` = {$target->id}" .
" WHERE `id` = {$this->id}");
// If the source is to the right of the target then we just adjusted its left and right above.
@@ -256,7 +256,7 @@ class ORM_MPTT_Core extends ORM {
$new_offset = $target->right - $left;
$this->db->query(
- "UPDATE `[{$this->table_name}]`" .
+ "UPDATE {{$this->table_name}}" .
" SET `left` = `left` + $new_offset," .
" `right` = `right` + $new_offset" .
" WHERE `left` >= $left" .
@@ -264,10 +264,10 @@ class ORM_MPTT_Core extends ORM {
// Close the hole in the source's parent after the move
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `left` = `left` - $size_of_hole" .
+ "UPDATE {{$this->table_name}} SET `left` = `left` - $size_of_hole" .
" WHERE `left` > $right");
$this->db->query(
- "UPDATE `[{$this->table_name}]` SET `right` = `right` - $size_of_hole" .
+ "UPDATE {{$this->table_name}} SET `right` = `right` - $size_of_hole" .
" WHERE `right` > $right");
} catch (Exception $e) {
$this->unlock();
diff --git a/core/tests/Database_Test.php b/core/tests/Database_Test.php
index e9ec5ebb..1e0764cc 100644
--- a/core/tests/Database_Test.php
+++ b/core/tests/Database_Test.php
@@ -86,16 +86,16 @@ class Database_Test extends Unit_Test_Case {
function prefix_replacement_test() {
$db = Database_For_Test::instance();
- $sql = "UPDATE `[access_caches]` SET `edit_1` = 1 " .
+ $sql = "UPDATE {access_caches} SET `edit_1` = 1 " .
"WHERE `item_id` IN " .
- " (SELECT `id` FROM `[items]` " .
+ " (SELECT `id` FROM {items} " .
" WHERE `left` >= 1 " .
" AND `right` <= 6)";
$sql = $db->add_table_prefixes($sql);
- $expected = "UPDATE `g3test_access_caches` SET `edit_1` = 1 " .
+ $expected = "UPDATE g3test_access_caches SET `edit_1` = 1 " .
"WHERE `item_id` IN " .
- " (SELECT `id` FROM `g3test_items` " .
+ " (SELECT `id` FROM g3test_items " .
" WHERE `left` >= 1 " .
" AND `right` <= 6)";
diff --git a/installer/installer.php b/installer/installer.php
index 9fec1185..9ea551a8 100644
--- a/installer/installer.php
+++ b/installer/installer.php
@@ -89,7 +89,7 @@ class installer {
$password = substr(md5(time() * rand()), 0, 6);
$hashed_password = $salt . md5($salt . $password);
$sql = self::prepend_prefix($config["prefix"],
- "UPDATE `[users]` SET `password` = '$hashed_password' WHERE `id` = 2");
+ "UPDATE {users} SET `password` = '$hashed_password' WHERE `id` = 2");
if (mysql_query($sql)) {
} else {
throw new Exception(mysql_error());
@@ -101,7 +101,7 @@ class installer {
static function create_private_key($config) {
$key = md5(uniqid(mt_rand(), true)) . md5(uniqid(mt_rand(), true));
$sql = self::prepend_prefix($config["prefix"],
- "INSERT INTO `[vars]` VALUES(NULL, 'core', 'private_key', '$key')");
+ "INSERT INTO {vars} VALUES(NULL, 'core', 'private_key', '$key')");
if (mysql_query($sql)) {
} else {
throw new Exception(mysql_error());
@@ -109,6 +109,6 @@ class installer {
}
static function prepend_prefix($prefix, $sql) {
- return preg_replace("#\[([a-zA-Z0-9_]+)\]#", "{$prefix}$1", $sql);
+ return preg_replace("#{([a-zA-Z0-9_]+)}#", "{$prefix}$1", $sql);
}
} \ No newline at end of file
diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php
index 47e354af..c1a30bd2 100644
--- a/modules/comment/controllers/admin_comments.php
+++ b/modules/comment/controllers/admin_comments.php
@@ -57,7 +57,7 @@ class Admin_Comments_Controller extends Admin_Controller {
public function index() {
// Get rid of old deleted/spam comments
Database::instance()->query(
- "DELETE FROM `[comments]` " .
+ "DELETE FROM {comments} " .
"WHERE state IN ('deleted', 'spam') " .
"AND unix_timestamp(now()) - updated > 86400 * 7");
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index a7852d05..5c5e9f03 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -23,7 +23,7 @@ class comment_installer {
$version = module::get_version("comment");
if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS `[comments]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {comments} (
`author_id` int(9) default NULL,
`created` int(9) NOT NULL,
`guest_email` varchar(128) default NULL,
@@ -58,10 +58,10 @@ class comment_installer {
static function uninstall() {
$db = Database::instance();
- $sql = "SELECT `item_id` FROM `[comments]`";
+ $sql = "SELECT `item_id` FROM {comments}";
module::event("item_related_update_batch", $sql);
- $db->query("DROP TABLE IF EXISTS `[comments]
+ $db->query("DROP TABLE IF EXISTS {comments]
`;");
module::delete("comment");
}
diff --git a/modules/exif/helpers/exif_installer.php b/modules/exif/helpers/exif_installer.php
index 964a9e6c..bd994bc3 100644
--- a/modules/exif/helpers/exif_installer.php
+++ b/modules/exif/helpers/exif_installer.php
@@ -23,7 +23,7 @@ class exif_installer {
if ($version == 0) {
$db = Database::instance();
- $db->query("CREATE TABLE IF NOT EXISTS `[exif_keys]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {exif_keys} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`name` varchar(64) NOT NULL,
@@ -32,7 +32,7 @@ class exif_installer {
PRIMARY KEY (`id`),
UNIQUE KEY(`item_id`, `summary`, `name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS `[exif_records]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {exif_records} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`dirty` BOOLEAN default 1,
@@ -44,7 +44,7 @@ class exif_installer {
static function uninstall() {
$db = Database::instance();
- $db->query("DROP TABLE IF EXISTS `[exif_keys]`;");
+ $db->query("DROP TABLE IF EXISTS {exif_keys};");
module::delete("exif");
}
}
diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php
index 6fdcdcf7..c26b209f 100644
--- a/modules/exif/helpers/exif_task.php
+++ b/modules/exif/helpers/exif_task.php
@@ -23,16 +23,16 @@ class exif_task_Core {
// Delete extra exif_records
$db->query(
- "DELETE `[exif_records]`.* FROM `exif_records` " .
- "LEFT JOIN `[items]` ON (`[exif_records]`.`item_id` = `[items]`.`id`) " .
- "WHERE `[items]`.`id` IS NULL");
+ "DELETE {exif_records}.* FROM `exif_records` " .
+ "LEFT JOIN {items} ON ({exif_records}.`item_id` = {items}.`id`) " .
+ "WHERE {items}.`id` IS NULL");
// Insert missing exif_records
$db->query(
- "INSERT INTO `[exif_record]`(`item_id`) (" .
- " SELECT `[items]`.`id` FROM `[items]` " .
- " LEFT JOIN `[exif_records]` ON (`[exif_records]`.`item_id` = `[items]`.`id`) " .
- " WHERE `[exif_records]`.`id` IS NULL)");
+ "INSERT INTO {exif_record}(`item_id`) (" .
+ " SELECT {items}.`id` FROM {items} " .
+ " LEFT JOIN {exif_records} ON ({exif_records}.`item_id` = {items}.`id`) " .
+ " WHERE {exif_records}.`id` IS NULL)");
list ($remaining, $total, $percent) = self::_get_stats();
return array(Task_Definition::factory()
diff --git a/modules/notification/helpers/notification_installer.php b/modules/notification/helpers/notification_installer.php
index 00fc82db..473ae169 100644
--- a/modules/notification/helpers/notification_installer.php
+++ b/modules/notification/helpers/notification_installer.php
@@ -23,7 +23,7 @@ class notification_installer {
$version = module::get_version("notification");
if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS `[subscriptions]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {subscriptions} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`user_id` int(9) NOT NULL,
@@ -38,7 +38,7 @@ class notification_installer {
static function uninstall() {
$db = Database::instance();
- $db->query("DROP TABLE IF EXISTS `[subscriptions]`;");
+ $db->query("DROP TABLE IF EXISTS {subscriptions};");
module::delete("notification");
}
diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php
index 05775fec..46f92e83 100644
--- a/modules/search/helpers/search_installer.php
+++ b/modules/search/helpers/search_installer.php
@@ -22,7 +22,7 @@ class search_installer {
$version = module::get_version("search");
$db = Database::instance();
if ($version == 0) {
- $db->query("CREATE TABLE `[search_records]` (
+ $db->query("CREATE TABLE {search_records} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9),
`dirty` boolean default 1,
@@ -32,7 +32,7 @@ class search_installer {
ENGINE=MyISAM DEFAULT CHARSET=utf8;");
// populate the index with dirty records
- $db->query("INSERT INTO `[search_records]` (`item_id`) SELECT `id` FROM `[items]`");
+ $db->query("INSERT INTO {search_records} (`item_id`) SELECT `id` FROM {items}");
module::set_version("search", 1);
if (ORM::factory("search_record")->count_all() < 10) {
@@ -47,7 +47,7 @@ class search_installer {
static function uninstall() {
$db = Database::instance();
- $db->query("DROP TABLE `[search_records]`");
+ $db->query("DROP TABLE {search_records}");
site_status::clear("search_index_out_of_date");
module::delete("search");
}
diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php
index 0071f2e0..7aba640e 100644
--- a/modules/search/helpers/search_task.php
+++ b/modules/search/helpers/search_task.php
@@ -21,16 +21,16 @@ class search_task_Core {
static function available_tasks() {
// Delete extra search_records
Database::instance()->query(
- "DELETE `[search_records]`.* FROM `[search_records]` " .
- "LEFT JOIN `[items]` ON (`[search_records]`.`item_id` = `[items]`.`id`) " .
- "WHERE `[items]`.`id` IS NULL");
+ "DELETE {search_records}.* FROM {search_records} " .
+ "LEFT JOIN {items} ON ({search_records}.`item_id` = {items}.`id`) " .
+ "WHERE {items}.`id` IS NULL");
// Insert missing search_records
Database::instance()->query(
- "INSERT INTO `[search_records]`(`item_id`) (" .
- " SELECT `[items]`.`id` FROM `[items]` " .
- " LEFT JOIN `[search_records]` ON (`[search_records]`.`item_id` = `[items]`.`id`) " .
- " WHERE `[search_records]`.`id` IS NULL)");
+ "INSERT INTO {search_records}(`item_id`) (" .
+ " SELECT {items}.`id` FROM {items} " .
+ " LEFT JOIN {search_records} ON ({search_records}.`item_id` = {items}.`id`) " .
+ " WHERE {search_records}.`id` IS NULL)");
list ($remaining, $total, $percent) = self::_get_stats();
return array(Task_Definition::factory()
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index 5604cb50..c0f6b9d7 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -50,10 +50,10 @@ class tag_event_Core {
static function item_before_delete($item) {
$db = Database::instance();
- $db->query("UPDATE `[tags]` SET `count` = `count` - 1 WHERE `count` > 0 " .
- "AND `id` IN (SELECT `tag_id` from `[items_tags]` WHERE `item_id` = $item->id)");
- $db->query("DELETE FROM `[tags]` WHERE `count` = 0 AND `id` IN (" .
- "SELECT `tag_id` from `[items_tags]` WHERE `item_id` = $item->id)");
+ $db->query("UPDATE {tags} SET `count` = `count` - 1 WHERE `count` > 0 " .
+ "AND `id` IN (SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)");
+ $db->query("DELETE FROM {tags} WHERE `count` = 0 AND `id` IN (" .
+ "SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)");
$db->delete("items_tags", array("item_id" => "$item->id"));
}
diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php
index 1345cadb..693551d0 100644
--- a/modules/tag/helpers/tag_installer.php
+++ b/modules/tag/helpers/tag_installer.php
@@ -22,7 +22,7 @@ class tag_installer {
$db = Database::instance();
$version = module::get_version("tag");
if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS `[tags]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {tags} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(64) NOT NULL,
`count` int(10) unsigned NOT NULL DEFAULT 0,
@@ -30,7 +30,7 @@ class tag_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS `[items_tags]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {items_tags} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`tag_id` int(9) NOT NULL,
@@ -44,8 +44,8 @@ class tag_installer {
static function uninstall() {
$db = Database::instance();
- $db->query("DROP TABLE IF EXISTS `[tags]`;");
- $db->query("DROP TABLE IF EXISTS `[items_tags]`;");
+ $db->query("DROP TABLE IF EXISTS {tags};");
+ $db->query("DROP TABLE IF EXISTS {items_tags};");
module::delete("tag");
}
}
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index 414327f5..c677d01a 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -23,7 +23,7 @@ class user_installer {
$version = module::get_version("user");
if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS `[users]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {users} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`full_name` varchar(255) NOT NULL,
@@ -41,7 +41,7 @@ class user_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS `[groups]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {groups} (
`id` int(9) NOT NULL auto_increment,
`name` char(64) default NULL,
`special` BOOLEAN default 0,
@@ -49,7 +49,7 @@ class user_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE IF NOT EXISTS `[groups_users]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {groups_users} (
`group_id` int(9) NOT NULL,
`user_id` int(9) NOT NULL,
PRIMARY KEY (`group_id`, `user_id`),
@@ -105,9 +105,9 @@ class user_installer {
} catch (Exception $e) {
}
$db = Database::instance();
- $db->query("DROP TABLE IF EXISTS `[users]`;");
- $db->query("DROP TABLE IF EXISTS `[groups]`;");
- $db->query("DROP TABLE IF EXISTS `[groups_users]`;");
+ $db->query("DROP TABLE IF EXISTS {users};");
+ $db->query("DROP TABLE IF EXISTS {groups};");
+ $db->query("DROP TABLE IF EXISTS {groups_users};");
module::delete("user");
}
} \ No newline at end of file
diff --git a/modules/watermark/helpers/watermark_installer.php b/modules/watermark/helpers/watermark_installer.php
index 70235b24..10ea3eb7 100644
--- a/modules/watermark/helpers/watermark_installer.php
+++ b/modules/watermark/helpers/watermark_installer.php
@@ -22,7 +22,7 @@ class watermark_installer {
$db = Database::instance();
$version = module::get_version("watermark");
if ($version == 0) {
- $db->query("CREATE TABLE IF NOT EXISTS `[watermarks]` (
+ $db->query("CREATE TABLE IF NOT EXISTS {watermarks} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`width` int(9) NOT NULL,
@@ -42,7 +42,7 @@ class watermark_installer {
static function uninstall() {
graphics::remove_rules("watermark");
module::delete("watermark");
- Database::instance()->query("DROP TABLE `[watermarks]`");
+ Database::instance()->query("DROP TABLE {watermarks}");
dir::unlink(VARPATH . "modules/watermark");
}
}