Welcome Guest, Not a member yet? Register   Sign In
returning multiple values from a function in a model
#1

[eluser]ag1060[/eluser]
Hello,

I have a function in a model named 'load_data($pid)' and it is suppose to get all the values from a mysql table...how can I make it so so it would return all values?


example:

function load_data($pid) {

$data['pusername'] = $this->project_model->find_user($puserid);
$data['progress'] = $this->project_model->find_progress($pid);


}

How do I return the values so I could do something like this:

function display_page($pid) {
$this->model_name->load_data($pid);
///all data from load_data should loaded and so...

$this->load->view('view',$data);

}


Is there a better approach to this or a solution?


Thanks in advance

}
#2

[eluser]Aken[/eluser]
Return an array or object.
#3

[eluser]CroNiX[/eluser]
Welcome to the forum! Please see my sig about putting your code in code tags.

You need to return $data from your load_data().
Then, in your display_page(), you would capture the returned data like
Code:
$data['model_data'] = $this->model_name->load_data($pid);
Then send $data as you are to the view, where you can access it as $model_data.




Theme © iAndrew 2016 - Forum software by © MyBB