Using something like NOW() in a Codeigniter insert array

codeigniter, php

Solution

Use the codeigniter date helper and keep the same notation:

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

$data = array('node1id' => $leader_id,
          'node2id' => $idgen,
          'friendsSince' => now(),
$this->db->insert('users', $data);

More info on date helper in CI docs here: http://ellislab.com/codeigniter/user_guide/helpers/date_helper.html

Problem

Because NOW() is a MySQL method I cannot seem to get it to work in the below array. What is a function I can use in PHP which will do the same thing as the NOW() method. ``` $data = array('node1id' => $leader_id, 'node2id' => $idgen, 'friendsSince' => NOW(), $this->db->insert('users', $data); ```

Original source

Related problems