What do you understand with "per second"?
The page loads and then, in each second the number of shown records grows with 5 ?
What’s the logic behind this, what do you try to achieve ?
If you want to show only the last 5 records, that’s simple:
$Company = Company::model()->findAll(array('limit'=>5,'order'=>'company_id DESC'));
If you want to display the latest 5 records in each second, you will need to do it in ajax like:
1)Have a separate controller that will serve you the latest 5 records from your table:
class SomeController extends Controller{
public function actionIndex()
{
$company = Company::model()->findAll(array('limit'=>5,'order'=>'company_id DESC'));
$this->renderPartial('someView',array('company'=>$company));
}
}
2)The view file of the separate controller
<div>
<php if(!empty($company)): foreach($company AS $c):?>
<div><?php echo $c->name;?></div>
<?php endforeach; endif;?>
</div>
Now, in the page where you will display these records, you will need a javascript function that will load the above records on every second, something like:
setTimeout(function(){
$('#result').load('<?php echo Yii::app()->createUrl('the-/controller/we previously/built');?>', function() {
console.log('Load was performed.');
});
},1000);
This javascript code, will query your controller every second, and will get the latest 5 results and put them in the current page in the <div id="result"></div> container.