php - How to get results of findBySQL -
sorry english. here code:
public function showlastthreenews(){ return news::model()->findbysql('select * news limit 3;'); }
next, example, want results of query:
public function actionindex() { $lastnews = $this->showlastthreenews(); foreach ($lastnews $news){ chromephp::log($lastnews->news_title); } $this->render('index', array( 'lastnews'=>$lastnews )); }
problem logger show me 1 record 3 times without changing next record.
what mistake?
you using wrong variable in loop change to,
foreach ($lastnews $news){ chromephp::log($news->news_title); }
Comments
Post a Comment