summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-13 10:38:28 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-13 10:38:28 +0000
commit0fe8d444722e6051a10fddd9e6b01b7c4849c5de (patch)
tree810dad2549c26495e3fad5ed6e39bdb638978730 /modules/comment
parent6d7130bffc2e124c9eed9fca3f772dcbd620fd12 (diff)
Create module helper and refactor all the code that creates, updates
and deletes modules into it.
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/helpers/comment_installer.php22
1 files changed, 5 insertions, 17 deletions
diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php
index 7e47ce8f..ac035929 100644
--- a/modules/comment/helpers/comment_installer.php
+++ b/modules/comment/helpers/comment_installer.php
@@ -21,19 +21,10 @@ class comment_installer {
public static function install() {
Kohana::log("debug", "comment_installer::install");
$db = Database::instance();
- try {
- $base_version = ORM::factory("module")->where("name", "comment")->find()->version;
- } catch (Exception $e) {
- if ($e->getCode() == E_DATABASE_ERROR) {
- $base_version = 0;
- } else {
- Kohana::log("error", $e);
- throw $e;
- }
- }
- Kohana::log("debug", "base_version: $base_version");
+ $version = module::get_version("comment");
+ Kohana::log("debug", "version: $version");
- if ($base_version == 0) {
+ if ($version == 0) {
$db->query("CREATE TABLE IF NOT EXISTS `comments` (
`id` int(9) NOT NULL auto_increment,
`author` varchar(255) default NULL,
@@ -44,16 +35,13 @@ class comment_installer {
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $comment_module = ORM::factory("module")->where("name", "comment")->find();
- $comment_module->name = "comment";
- $comment_module->version = 1;
- $comment_module->save();
+ module::set_version("comment", 1);
}
}
public static function uninstall() {
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS `comments`;");
- ORM::factory("module")->where("name", "comment")->find()->delete();
+ module::delete("comment");
}
}