私の英語でごめんなさい。コードは次のとおりです。
public function showLastThreeNews(){
return News::model()->findBySql('SELECT * FROM news LIMIT 3;');
}
次に、たとえば、クエリの結果を取得したい:
public function actionIndex()
{
$lastnews = $this->showLastThreeNews();
foreach ($lastnews as $news){
ChromePhp::log($lastnews->news_title);
}
$this->render('index', array(
'lastnews'=>$lastnews
));
}
問題は、ロガーが次のレコードに変更せずに 1 つのレコードを 3 回表示することです。
私の間違いは何ですか?