Issues with $this->db->insert - 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: Issues with $this->db->insert (/showthread.php?tid=1927) |
Issues with $this->db->insert - El Forum - 07-05-2007 [eluser]awpti[/eluser] Code: function comments_insert() { Taken from the sample blog tutorial. Does db->insert not kick off a NOW() function on DATETIME fieldtypes? Seems to always leave the value NULL. Is there a way to get it to fire off NOW(), or do I need to format a string to pass with it? Issues with $this->db->insert - El Forum - 07-05-2007 [eluser]champs[/eluser] All strings passed to Active Record are inserted as strings, so NOW() is wrapped in quotes, just like everything else, and you will need a function that returns the date string you need. In MySQL, you've got an ON UPDATE CURRENT_TIMESTAMP attribute (that you can set on ONE field, IIRC), but if you have multiple date fields, don't bother. And just to get out ahead of you, a special exception for NOW() means special exceptions for *every* pet function someone cares to use in their statements. |