title: CI insert into database with default field if value is null
body: <p>I am trying to insert into my database table.</p>
  
  <p>I am getting this error from the column:</p>
  
  <pre><code>Column 'allow_edit_time_due' cannot be null
  </code></pre>
  
  <p>But, the column is set to default: '0'</p>
  
  <p>How can I just insert into my table if 'allow_edit_time_due' is null, so that the value is the default value?</p>
  
  <p>query:</p>
  
  <pre><code>$sql = "INSERT INTO `cal_tasks` (user_id, task, task_notes, task_type, allow_edit_time_due, task_time_due, user_created) VALUES (" . $this-&gt;db-&gt;escape($user_id) . ", " . $this-&gt;db-&gt;escape($data['task']) . ", " . @$this-&gt;db-&gt;escape($data['task_notes']) . ", " . @$this-&gt;db-&gt;escape($data['task_type']) . ", " . @$this-&gt;db-&gt;escape($data['allow_edit_time_due']) . ", " . $this-&gt;db-&gt;escape($data['task_time_due']) . ", " . @$this-&gt;db-&gt;escape($data['user_created']) . ")";
  </code></pre>