Welcome Guest, Not a member yet? Register   Sign In
Restrict CodeIgniter Active Record Cache to only one object
#1

[eluser]Unknown[/eluser]
Let's say I have a model for the current user and a model for an userlist. In the model for the userlist I cache the WHERE statements because if I don't, I have to apply them all again after the use of $this->db->count_all_results (that function resets active record functions). I off course need those also for the $this->db->get('users').

The functions in the userlist model to filter users look like this:
Code:
public function onlyWomen()
{
$this->db->start_cache();
$this->db->where('gender', '1');
$this->db->stop_cache();
}
Problem is that i'm also working with a model for the current user. I suspect the cache I set in the userlist model to also copy to de current user model (i'm working with both at the same time, so I can't flush the cache when starting with the current user model). I thought the active record cache should stay in the object in wich it is called.

How do I circumvent or resolve this?

(My English ain't that bad, but in combination with this complicated stuff and me maybe not fully understanding objects/classes, I hope you understand my problem ^^)

EDIT: db->get is somewhat narrower than te db->count_all_results (the get has a limit). This is because of pagination. This is also why I can't simply apply a count of rows AFTER the get.




Theme © iAndrew 2016 - Forum software by © MyBB