Enable caching related models
This commit is contained in:
parent
e8c4f00a8d
commit
1e88be0e21
@ -345,6 +345,7 @@ class Kohana_ORM extends Model implements serializable {
|
||||
}
|
||||
|
||||
$defaults = array();
|
||||
$defaults['cached'] = FALSE;
|
||||
|
||||
foreach ($this->_belongs_to as $alias => $details)
|
||||
{
|
||||
@ -650,6 +651,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();
|
||||
}
|
||||
|
||||
@ -677,6 +682,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;
|
||||
@ -709,6 +718,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
|
||||
@ -729,6 +742,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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user