![]() |
Datamapper and date not saving - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Datamapper and date not saving (/showthread.php?tid=39824) |
Datamapper and date not saving - El Forum - 03-21-2011 [eluser]night_day[/eluser] I've got CI2 and DM 1.8 working fine. My object saves fine from a post, except one field (date_occuring) doesn't save. Code: $event = new Event(); Event has only those three columns and an id column. The name and description get saved properly. I echo the $event->date_occuring and it`s returning a valid date (3/17/2011 for example) The field is setup as datetime in the DB, not sure what else I might be doing wrong here. Please let me know if you have any thoughts. Datamapper and date not saving - El Forum - 03-22-2011 [eluser]WanWizard[/eluser] Start by using $event->check_last_query() after the save. What does it tell you? My assumption is that you're trying to store the string '3/17/2011' in the datetime field, which is not going to work. Datetime needs a string in the form "YYYY-MM-DD HH:MM:SS" (with or without delimiters, and some shorthand is possible). Datamapper and date not saving - El Forum - 03-22-2011 [eluser]night_day[/eluser] Thanks WanWizard, you were right, I just had the wrong format going in, everything works fine now! |