summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-11-23 18:00:44 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-11-23 18:00:44 +0000
commitab20406ef21c1011c2a4b189e8340dc7ee87a813 (patch)
tree76c41946b86675f42d56e03350605fc49923d61c /modules
parent7491e3c44affb89fe28030f8759283bc1b4aa291 (diff)
Tag module database definitions
Diffstat (limited to 'modules')
-rw-r--r--modules/tag/helpers/tag_installer.php17
-rw-r--r--modules/tag/models/tag.php25
2 files changed, 42 insertions, 0 deletions
diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php
index 03823ff3..7c10be97 100644
--- a/modules/tag/helpers/tag_installer.php
+++ b/modules/tag/helpers/tag_installer.php
@@ -20,14 +20,31 @@
class tag_installer {
public static function install() {
Kohana::log("debug", "tag_installer::install");
+ $db = Database::instance();
$version = module::get_version("tags");
Kohana::log("debug", "tag: $version");
if ($version == 0) {
+ $db->query("CREATE TABLE IF NOT EXISTS `tags` (
+ `id` int(9) NOT NULL auto_increment,
+ `tag_text` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`display_name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+
+ $db->query("CREATE TABLE IF NOT EXISTS `items_tags` (
+ `item_id` int(9) NOT NULL,
+ `tag_id` int(9) NOT NULL,
+ PRIMARY KEY (`item_id`, `tag_id`),
+ UNIQUE KEY(`tag_id`, `item_id`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
module::set_version("tag", 1);
}
}
public static function uninstall() {
+ $db = Database::instance();
+ $db->query("DROP TABLE IF EXISTS `tags`;");
+ $db->query("DROP TABLE IF EXISTS `items_tags`;");
module::delete("tag");
}
}
diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php
new file mode 100644
index 00000000..0bf85843
--- /dev/null
+++ b/modules/tag/models/tag.php
@@ -0,0 +1,25 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2008 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Tag_Model extends ORM {
+ protected $has_and_belongs_to_many = array("items");
+
+ var $rules = array(
+ "name" => "required|length[4,32]");
+} \ No newline at end of file