![]() |
Model/Database question - 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: Model/Database question (/showthread.php?tid=2680) |
Model/Database question - El Forum - 08-18-2007 [eluser]Hamilogre[/eluser] I'm trying to run an update in my model by passing $this to the $this->db->insert function. When I run it, it seems that it is trying to pass more than just my class variables to the insert statement. Here is the output: Code: An Error Was Encountered Am I doing something wrong that is making it so that things outside of my class variables are being passed to the function? Model/Database question - El Forum - 08-18-2007 [eluser]Michael Wales[/eluser] The best way to accomplish inserts and updates is to place all of your variables into an array and pass that array to the function: Code: $insert = array('doctor_first_name'=>$this->input->post('doctor_first_name'), Model/Database question - El Forum - 08-18-2007 [eluser]Hamilogre[/eluser] [quote author="walesmd" date="1187486358"]The best way to accomplish inserts and updates is to place all of your variables into an array and pass that array to the function: Code: $insert = array('doctor_first_name'=>$this->input->post('doctor_first_name'), Got ya. But isn't that repetitive? Because if I also want to set the class variables for the object I will need to set the separately... Model/Database question - El Forum - 08-18-2007 [eluser]Rick Jolly[/eluser] Yup, just pass the $_POST array into the active record insert/update. That is providing that the data has been validated. Note that the validator class acts directly on the $_POST array, therefore once validation has been done, the $_POST array is safe. |