Inserting NOW() into Database with CodeIgniter's Active Record

后端 未结 11 1060
傲寒
傲寒 2020-12-01 02:15

I want to insert current time in database using mySQL function NOW() in Codeigniter\'s active record. The following query won\'t work:

$data = array(
                


        
11条回答
  •  醉酒成梦
    2020-12-01 03:12

    Using the date helper worked for me

    $this->load->helper('date');
    

    You can find documentation for date_helper here.

    $data = array(
      'created' => now(),
      'modified' => now()
    );
    
    $this->db->insert('TABLENAME', $data);
    

提交回复
热议问题