I am trying to get information from the table through the module (I want to create a news editing method):

foreach ($this->newsList as $item){ $item->item['id']; } 

But it gives an error:

Undefined property: View :: $ newsList ...
Warning: Invalid argument supplied for foreach ()

Module code looks like this:

 public function newsList() { return $this->db->select('SELECT id, title, message, newslink, imagelink, realms FROM news'); } 

And controller:

 $this->view->newsList = $this->model->newsList(); $this->view->render('editnews/index'); 

Please help me resolve the issue.

    1 answer 1

     foreach ($this->newsList() as $item) { $item->item['id']; }