You are setting $limit
to count($files)
but using $i<=$limit
in your loop. Should be <
instead.
for($i=0; $i<$limit; $i++){
Since there is a chance of an external $limit
being applied you could use a foreach
loop with a conditional break
.
foreach($files as $a => $file) {
if($a == $limit) {
break;
}
$file->date = date('Y:m:d H:i:s');
$file->update();
}
Note that findAll()
without a limit
retrieves all the records from the databases for that table. Perhaps you should consider adding the limit through CDbCriteria