![]() |
Something wrong in my model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Something wrong in my model (/showthread.php?tid=64550) |
Something wrong in my model - brian85 - 03-03-2016 Hi, I'm working in CI 2.2 I'm having trouble with my model : PHP Code: class Stages_model extends CI_Model { and when I'm calling the function find in a loop in my controller like that : PHP Code: foreach ($array_selection as $key_sel => $idStage) { The dump of $data['satges'] show the same result : the last value. ![]() It seems that returning the instance affects all values in the array, how is it possible ? How can I get in my array different instances of my model object in $data[''stages'] ? Thanks for your help ![]() [SOLVED]RE: Something wrong in my model - brian85 - 03-03-2016 I answer myself I've found the way here is my corrected model function find() : PHP Code: public function find($value) { Now it works perfectly ! ![]() I hope this could help see you next time, I really enjoy CI my next project will use CI 3 RE: [SOLVED]RE: Something wrong in my model - pdthinh - 03-03-2016 I think you can use PHP clone keyword PHP Code: foreach ($array_selection as $key_sel => $idStage) { RE: Something wrong in my model - brian85 - 03-04-2016 Thanks for this trick I'll test it soon ![]() |