diff --git a/modules/orm/classes/Kohana/ORM.php b/modules/orm/classes/Kohana/ORM.php index 21b47a1..2b20ea2 100644 --- a/modules/orm/classes/Kohana/ORM.php +++ b/modules/orm/classes/Kohana/ORM.php @@ -342,6 +342,7 @@ class Kohana_ORM extends Model implements serializable { } $defaults = array(); + $defaults['cached'] = FALSE; foreach ($this->_belongs_to as $alias => $details) { @@ -647,6 +648,10 @@ class Kohana_ORM extends Model implements serializable { // See: http://mysql.localhost.net.ar/doc/refman/5.1/en/server-session-variables.html#sysvar_sql_auto_is_null if ($val !== NULL) { + // Enable caching query + if ($this->_belongs_to[$column]['cached']) + $model->cached(); + $model->where($col, '=', $val)->find(); } @@ -674,6 +679,10 @@ class Kohana_ORM extends Model implements serializable { } } + // Enable caching query + if ($this->_has_one[$column]['cached']) + $model->cached(); + $model->where($col, '=', $val)->find(); return $this->_related[$column] = $model; @@ -706,6 +715,10 @@ class Kohana_ORM extends Model implements serializable { $val = $this->_object[$this->_has_many[$column]['far_key']]; } + // Enable caching query + if ($this->_has_many[$column]['cached']) + $model->cached(); + return $model->where($col, '=', $val); } else @@ -726,6 +739,10 @@ class Kohana_ORM extends Model implements serializable { $model = $model->where($col, '=', $val); } + // Enable caching query + if ($this->_has_many[$column]['cached']) + $model->cached(); + return $model; } }