How to insert null date using ActiveRecord? - 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 to insert null date using ActiveRecord? (/showthread.php?tid=55864) |
How to insert null date using ActiveRecord? - El Forum - 11-13-2012 [eluser]jprateragg[/eluser] I need to insert a null date using ActiveRecord. I have a helper function that converts the date to the MySQL date format: Code: function convert_date($input) { Here is my model where I save the data: Code: public function save_analysis_history($data) { This is the error I'm getting: Code: Error Number: 1292 Is it possible to get ActiveRecord to not add single quotes to NULL? How to insert null date using ActiveRecord? - El Forum - 11-13-2012 [eluser]PhilTem[/eluser] Code: function convert_date($input) { Or you set the table field column to "DEFAULT NULL" How to insert null date using ActiveRecord? - El Forum - 11-13-2012 [eluser]Aken[/eluser] Just use PHP's standard NULL value, instead of passing a string "NULL". How to insert null date using ActiveRecord? - El Forum - 11-14-2012 [eluser]jprateragg[/eluser] @PhilTem and Aken--that fixed it. Thanks! |