Welcome Guest, Not a member yet? Register   Sign In
Handling insert of optional date fields
#1

[eluser]MatBeard[/eluser]
I've got a form with around 20 fields, only two of which are required. Of the others, there are 2 or 3 date fields (which are defaulted to NULL in the schema).

I'm trying keep things as simple as possible, so I'm using something along the lines of:
Code:
$this->db->insert('mytable', $this->input->post(NULL,true));
to create a new record.

This is failing because the optional date fields are trying to be inserted as empty strings.

I can think of a number of ways around this, but I figured that this is such a common issue, there must be a 'CI approved' way of dealing with it.

If so, what is it?

Thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB