Hi,
I’m using CDbCacheDependency to execute a statement only, if there are new rows in an table.
$dependency = new CDbCacheDependency('SELECT MAX(LFNR) FROM ' . $table);
$connection = Yii::app()->db->cache(3600, $dependency);
$res = $connection
->createCommand()
But now, -i need to change this a bit. The statement should be only executed, if the dependency has changed AND if one additional check is true. So I think, this is an adequate solution:
$dependency = new CDbCacheDependency('SELECT MAX(LFNR) FROM ' . $table);
if ($dependency->hasChanged == true AND $this->myAdditionCheck == true)
{
$connection = Yii::app()->db->cache(3600, $dependency);
$res = $connection
->createCommand()
But the problem is: $dependency->hasChanged always returned true even SELECT MAX(LFNR) FROM … does not contain new data.
So:
1.) why $dependency->hasChanged is alwas true and
2.) how to inject an 2nd dependency, that is not SQL?
Thank you,
rall0r