Welcome Guest, Not a member yet? Register   Sign In
Array To String error / undefined $query
#17

I really think you need to redesign the render functions in both your MY_Controller class as the Admin_Controller class. Because Admin_Controller extends MY_Controller, they must have the same set of parameters.
Now, from your controller, you not only wish to pass the view and template, but also some data that has been collected from your database (via a Model). This requires a third parameter for both render functions.

Simplified example:

Controller:
PHP Code:
$data['query'] = $this->Docs_model->viewexisting();
$this->render('admin/docs/existing_view',NULL,$data);  //NULL says: use the default template 

MY_Controller (class MY_Controller AND class Admin_Controller!!!):
PHP Code:
public function render($view 'default_view'$template 'default_template'$data NULL);
$this->load->view('templates/' $template $view$data); 

$data is an array. In this example, it only contains the 'query' element, but you can pass as many elements in one $data array as you want. The $data array is automatically exploded to seperate variables when it's passed to a view.
So in the view, you can refer to $query. If $query itself is an array (in this case it's an array of objects), you can loop through it's elements with foreach(...).
Hope this will help you.
Reply


Messages In This Thread
RE: Array To String error / undefined $query - by Wouter60 - 08-18-2016, 10:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB