diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-28 16:48:29 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-06-28 16:48:29 -0700 |
commit | fcc57a418245b6cac410f70506f6f4b687c8a98a (patch) | |
tree | 94ea320de4d5c040c302ec1ed162af6c6b6a9fd8 /modules/gallery/libraries/drivers | |
parent | aa31e1f0090522c3cfb3a44b947ad8c33a275979 (diff) |
Modify the cache table to make id the primary key for consistency with
other gallery 3 tables. Update the driver to match, add more upgrader
code, update the installer block and change the gallery module version
to 6.
Diffstat (limited to 'modules/gallery/libraries/drivers')
-rw-r--r-- | modules/gallery/libraries/drivers/Cache/Database.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 158f7b3a..f3a1eb02 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -32,9 +32,8 @@ class Cache_Database_Driver implements Cache_Driver { $this->db = Database::instance(); if (!$this->db->table_exists("caches")) { - throw new Kohana_Exception("cache.driver_error", "Cache table is not defined"); + throw new Exception("@todo Cache table is not defined"); } - Kohana::log("debug", "Cache Database Driver Initialized"); } /** @@ -44,7 +43,7 @@ class Cache_Database_Driver implements Cache_Driver { * @return boolean */ public function exists($id) { - $count = $this->db->count_records("caches", array("id" => $id, "expiration >=" => time())); + $count = $this->db->count_records("caches", array("key" => $id, "expiration >=" => time())); return $count > 0; } @@ -70,10 +69,10 @@ class Cache_Database_Driver implements Cache_Driver { if ($this->exists($id)) { $status = $this->db->update("caches", - array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("id" => $id)); + array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("key" => $id)); } else { $status = $this->db->insert("caches", - array("id" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); + array("key" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); } return count($status) > 0; @@ -119,7 +118,7 @@ class Cache_Database_Driver implements Cache_Driver { */ public function get($id) { $data = null; - $result = $this->db->getwhere("caches", array("id" => $id)); + $result = $this->db->getwhere("caches", array("key" => $id)); if (count($result) > 0) { $cache = $result->current(); @@ -157,7 +156,7 @@ class Cache_Database_Driver implements Cache_Driver { } else if ($tag === true) { $this->db->like("tags", "<$id>"); } else { - $this->db->where("id", $id); + $this->db->where("key", $id); } $status = $this->db->delete(); |