Created
November 16, 2011 19:02
-
-
Save mikedfunk/1370989 to your computer and use it in GitHub Desktop.
Using MySQL NOW() in Codeigniter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Using MySQL NOW() in Codeigniter | |
// by daveganley | |
// There are two easy ways to do this | |
// With NOW() | |
$data = array( | |
'field_name' => 'some_data' | |
); | |
$this->db->set('date_field_name', 'NOW()', FALSE); | |
$this->db->insert('table_name', $data); | |
// The FALSE in the set method prevents the NOW() being escaped | |
// Without NOW() | |
$now = date('Y-m-d H:i:s'); | |
$data = array( | |
'field_name' => 'some_data', | |
'date_field_name' => $now | |
); | |
$this->db->insert('table_name', $data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
field_name