PAgination witha foreach loop

Hi,

how can i use the yii’s pager with a foreach loop ?

for what purpose?!

Well i want to make some chache things with an sql query and then, i want to add pagination to the result :




$sql="SELECT id,title,description,date FROM news WHERE idcompany =".Yii::app()->user->idcompany." LIMIT 1,2";

            $dependency = new CDbCacheDependency('SELECT MAX(timestamp) FROM news WHERE idcompany ='.Yii::app()->user->idcompany);

            // $dependency->connectionID='dbshare';

            $rows = Yii::app()->db->cache(7200, $dependency)->createCommand($sql)->queryAll();

            



I want to make the pagination for $rows…

Create a CArrayDataProvider

with your result rows.

See this topic too.

Thanx so mutch ! this is exactmy what i needed :)