php-activerecord
php-activerecord copied to clipboard
When memcache is enabled, all queries result same values
I have a Model ImplementingAgency.php ImplementingAgency extends ActiveRecord\Model { static $cache = TRUE; function Targets() { $count = Model1::find_by_sql("select count(id) as total where implementing_agency_id = {$this->id}"); return $ocunt[0]->total; } function Assignments() { $count = Model2::find_by_sql("select count(id) as total where implementing_agency_id = {$this->id}"); return $ocunt[0]->total; } }
Now the problem is, when i call these two functions on same page, both return same result when cache is set to TRUE and when i set it to FALSE, both starts returning correct result. Can you please tell why?
$this->id evaluates to the same value in both cases? If that's the case I think queries are cached over all models and not model independent..
Yes they refer to the current ImplementingAgency class instance from database. But i couldn't understand your explanation here. If you could please tell me how's it working?