summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/model_cache.php
diff options
context:
space:
mode:
authorNathan Kinkade <nkinkade@nkinka.de>2010-01-19 16:34:34 +0000
committerNathan Kinkade <nkinkade@nkinka.de>2010-01-19 16:34:34 +0000
commite47505081f2c1017a68f763e1170b44fddd1e722 (patch)
treeeb511a8d9bae266ed6cf86f789f270642af93e90 /modules/gallery/helpers/model_cache.php
parent0a67b836a9b5021c91b9c327d3693991c3248dfc (diff)
parent9384f987bb96d0d39787ff9d3d16a70c01cd76e0 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers/model_cache.php')
-rw-r--r--modules/gallery/helpers/model_cache.php14
1 files changed, 6 insertions, 8 deletions
diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php
index 302e42d9..88756407 100644
--- a/modules/gallery/helpers/model_cache.php
+++ b/modules/gallery/helpers/model_cache.php
@@ -18,27 +18,25 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class model_cache_Core {
- private static $cache;
+ private static $cache = array();
static function get($model_name, $id, $field_name="id") {
- if (TEST_MODE || empty(self::$cache->$model_name->$field_name->$id)) {
+ if (TEST_MODE || empty(self::$cache[$model_name][$field_name][$id])) {
$model = ORM::factory($model_name)->where($field_name, "=", $id)->find();
if (!$model->loaded()) {
throw new Exception("@todo MISSING_MODEL $model_name:$id");
}
- self::$cache->$model_name->$field_name->$id = $model;
+ self::$cache[$model_name][$field_name][$id] = $model;
}
- return self::$cache->$model_name->$field_name->$id;
+ return self::$cache[$model_name][$field_name][$id];
}
static function clear() {
- self::$cache = new stdClass();
+ self::$cache = array();
}
static function set($model) {
- self::$cache->{$model->object_name}
- ->{$model->primary_key}
- ->{$model->{$model->primary_key}} = $model;
+ self::$cache[$model->object_name][$model->primary_key][$model->{$model->primary_key}] = $model;
}
}