CodeIgniter Forums
Use of sysdate() for MySQL not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Use of sysdate() for MySQL not working (/showthread.php?tid=9660)



Use of sysdate() for MySQL not working - El Forum - 07-03-2008

[eluser]extra_rice[/eluser]
the trans_datetime doesn't return the current date...
Code:
$data = array(
                'username' => $username,
                'lastname' => $lastname,
                'firstname' => $firstname,
                'middlename' => $middlename,
                'status' => 0,
                'pass_attr' => 0,
                'password' => $password,
                'landline_number' => $landlineNumber,
                'mobile_number' => $mobileNumber,
                'email' => $email,
                'trans_datetime' => 'sysdate()',
                'trans_user' => 0
        );
        
        $this->obj->db->insert($this->table, $data);

and this one without the single quote gives a PHP error...
Code:
$data = array(
                'username' => $username,
                'lastname' => $lastname,
                'firstname' => $firstname,
                'middlename' => $middlename,
                'status' => 0,
                'pass_attr' => 0,
                'password' => $password,
                'landline_number' => $landlineNumber,
                'mobile_number' => $mobileNumber,
                'email' => $email,
                'trans_datetime' => sysdate(),
                'trans_user' => 0
        );
        
        $this->obj->db->insert($this->table, $data);

any solutions guys?


Use of sysdate() for MySQL not working - El Forum - 07-03-2008

[eluser]johnwbaxter[/eluser]
What does 'trans_datetime' return in your first example if it's not returning the current date?


Use of sysdate() for MySQL not working - El Forum - 07-03-2008

[eluser]Seppo[/eluser]
Code:
$this ->obj->db->set('trans_datetime', 'sysdate()', FALSE);
$data = array(
                'username' => $username,
                'lastname' => $lastname,
                'firstname' => $firstname,
                'middlename' => $middlename,
                'status' => 0,
                'pass_attr' => 0,
                'password' => $password,
                'landline_number' => $landlineNumber,
                'mobile_number' => $mobileNumber,
                'email' => $email,
                'trans_user' => 0
        );
$this->obj->db->insert($this->table, $data);



Use of sysdate() for MySQL not working - El Forum - 07-04-2008

[eluser]extra_rice[/eluser]
@audiopleb: thanks for the reply dude... just solved it using Seppo's solution

@Seppo: thanks dude! never thought i'd have to do it like that... thanks again!