![]() |
returning multiple values from a function in a model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: returning multiple values from a function in a model (/showthread.php?tid=51956) |
returning multiple values from a function in a model - El Forum - 05-24-2012 [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 } returning multiple values from a function in a model - El Forum - 05-24-2012 [eluser]Aken[/eluser] Return an array or object. returning multiple values from a function in a model - El Forum - 05-24-2012 [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); |