![]() |
Unknown column - 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: Unknown column (/showthread.php?tid=12331) |
Unknown column - El Forum - 10-15-2008 [eluser]umefarooq[/eluser] Hi im posting data from form to model after getting all post it give me this error.Unknown column '_module' here is my code Code: $this->db->insert('flipp_settings',$this); Unknown column - El Forum - 10-15-2008 [eluser]GSV Sleeper Service[/eluser] take a look at the active record insert example. - http://ellislab.com/codeigniter/user-guide/database/examples.html the second parameter to db->insert should be an associative array of values. you are passing $this as the second parameter, and $this refers to the CI superobject. Unknown column - El Forum - 10-15-2008 [eluser]umefarooq[/eluser] ya you are right but here in this exmaple you can see what is the difference. because im following the same way in following example. Model Unknown column - El Forum - 10-15-2008 [eluser]GSV Sleeper Service[/eluser] hmmm, that's a very confusing example. what else does $this contain? Unknown column - El Forum - 10-15-2008 [eluser]wiredesignz[/eluser] $this = the model object, and the db driver will try to use every class variable of the model object to build it's insert SQL, as per the example you show. Unless your table has a _module column I recommend that you change the way you are using insert because your model object appears to have class variables that are not in your table. Unknown column - El Forum - 10-15-2008 [eluser]Colin Williams[/eluser] I don't think Models should be used to represent objects, as you are doing in this context. I mean, you certainly can do it, but you need to consider the constraints and caveats of doing this. |