![]() |
How can I use active record to insert DEFAULT VALUE? - 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: How can I use active record to insert DEFAULT VALUE? (/showthread.php?tid=41909) |
How can I use active record to insert DEFAULT VALUE? - El Forum - 05-20-2011 [eluser]fell0206[/eluser] Hello everybody, I have a problem with the active record of insert. My table have a "Root" of column(not null), it have a default value(0), I create a class, and I use "$this->db->insert('mytable',$data);" to insert the record, but when the variable "Root" is null, then the error will occur. How can I fix this error!! Thanks~ MyTable: Code: CREATE TABLE IF NOT EXISTS `test` ( MyClass: Code: class MyClass{ Controller: Code: ... Model: Code: ... How can I use active record to insert DEFAULT VALUE? - El Forum - 05-21-2011 [eluser]theprodigy[/eluser] Not sure if what you show in your code is copy/pasted, but shouldn't Code: ... be Code: ... Also, what is the output of this? Code: function add($myClass){ How can I use active record to insert DEFAULT VALUE? - El Forum - 06-06-2011 [eluser]fell0206[/eluser] Sorry, it's my fault. In my file it is correct: Code: $myClass->A=$this->input->post('A'); About insert string, if variable not set, it will be NULL.(if column have CURRENT_TIMESTAMP and AUTO_INCREAMENT, it work corrent). How can I fix it, thank you~ How can I use active record to insert DEFAULT VALUE? - El Forum - 06-06-2011 [eluser]theprodigy[/eluser] Quote:About insert string, if variable not set, it will be NULL.I'm looking for the ACTUAL output of the string, not 'what it will be'. Please run the code, and copy/paste the output of it. |