SupFrig
SupFrig

Reputation: 365

codeigniter - insert return true, without modifying database

I got this update script in a for :

if(isset($_POST[$i+1 . '_create_metier'])){
  $new_entry = array(
    'id_parent' => $current[0]->id,
    'work' => $_POST[$i+1 . '_create_metier'],
    'days' => $_POST[$i+1 . '_create_daycount'],
    'price' => $_POST[$i+1 . '_create_price'],
    'cr_date' => date('d-m-Y H:i:s'),
    'user' => ''
  );
  var_dump($new_entry);
  if(!$this->db->insert('meta_parent',$new_entry)){
    echo 'fail';
    $p3 = 0;
  }else{
    echo 'success';
  }
}

The var_dump return a well filled array for my db structure, and 'success' is printed, implying the query worked.

But i don't get any modification in my DB. It's not my first use of codeigniter and i never had such an issue.

Thanks for help

Upvotes: 2

Views: 2519

Answers (1)

Massimiliano Marini
Massimiliano Marini

Reputation: 499

I think the error is in the date format, MySQL accept the date in this format: Y-m-d H:i:s

Try replacing

'cr_date' => date('d-m-Y H:i:s'),

with

'cr_date' => date('Y-m-d H:i:s'),

Upvotes: 1

Related Questions