CDbCacheDependency: get result of query

So, i have cached news in controller




$sql = 'SELECT MAX(updated) FROM `'.Yii::app()->params['cacheTable'].'` WHERE `obj`="'.News::model()->getAttribute('table').'"';

$dependency = new CDbCacheDependency($sql);

$criteria=new CDbCriteria;

$news = News::model()->cache(Yii::app()->params['cacheTime'], $dependency)->find($criteria);

...



works fine!

Watching the sql-log i find query to database:


SELECT MAX(updated) FROM `cache` WHERE `obj`="news"

dependency query, sure!

How can i get the resul of this query in my view-code?

without extra query, of couse…

Do you mean you want to use variables in your view? Take a look at $data in CController.render.

Example




$this->render('index', array(

	'news' => $news,

);



Now you can work with $news in your ‘index’-view.

regards, hofrob

i’ve no problems with rendering

i want get result of this query


SELECT MAX(updated) FROM `cache` WHERE `obj`="news"

i need "updated" value

can i get it using $news object?

Binding the column should do it:

http://www.yiiframework.com/doc/guide/1.1/en/database.dao#binding-columns

i’m using ActiveRecord

seems it hasn’t binding :(

i can do that caching without AR, but it is more comfortable use AR with dependency

Have you tried $dependency->dependentData?

Has solved, man! ;)

Huge thx!