Welcome Guest, Not a member yet? Register   Sign In
Datamapper and date not saving
#1

[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->name =  $this->input->post("name");
$event->description = $this->input->post("description");
$event->date_occuring = $this->input->post("event_date");

$event->save();

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.
#2

[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).
#3

[eluser]night_day[/eluser]
Thanks WanWizard, you were right, I just had the wrong format going in, everything works fine now!




Theme © iAndrew 2016 - Forum software by © MyBB