[eluser]leonardteo[/eluser]
Hi guys,
I'm trying to find the cleanest way to use the MySQL NOW() function when inserting into a database using Active Record. Anyone know how to do this?
In my controller I have this:
Code:
function _doregister(){
//Hash the password
$password = dohash($this->input->post('password'));
//set the data, load the model, insert user
$data = array(
'email' => $this->input->post('email'),
'firstname' => $this->input->post('firstname'),
'lastname' => $this->input->post('lastname'),
'password' => $password,
'username' => $this->input->post('username'),
'created' => 'now()' //THIS ISN'T WORKING!!!!
);
$this->load->model('User_model');
$this->User_model->insert($data);
echo "Inserted user";
}
In the model I have this:
Code:
function insert($data){
$this->db->insert('users', $data);
}
I think what's happening above is that the 'created' => 'now()' is wrapping the NOW() function in quotes during the actual mysql query, so the date always sets to "0000-00-00 00:00:00" in the database.
Help?
Thanks,
Leonard