Yii Framework Forum: Cdbcachedependency -> Haschanged Is Allwas True - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cdbcachedependency -> Haschanged Is Allwas True Rate Topic: -----

#1 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 11-November 10
  • Location:Bln

Posted 23 May 2014 - 05:44 AM

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
0

#2 User is offline   rall0r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 11-November 10
  • Location:Bln

Posted 26 May 2014 - 05:14 AM

No idea, hint or workaround? Hmm... :huh:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users