php-activerecord icon indicating copy to clipboard operation
php-activerecord copied to clipboard

When memcache is enabled, all queries result same values

Open raakeshkumar opened this issue 10 years ago • 2 comments

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?

raakeshkumar avatar Jan 30 '15 11:01 raakeshkumar

$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..

koenpunt avatar Jan 30 '15 13:01 koenpunt

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?

raakeshkumar avatar Jan 30 '15 13:01 raakeshkumar