[eluser]mariowarner[/eluser]
i just had the same problem and was able to fix it. here's how i did it.
assuming i have a guestbook table with the following structure:
Code:
CREATE TABLE IF NOT EXISTS `guestbook_table` (
`inc_no` smallint(5) NOT NULL auto_increment,
`name` varchar(30) NOT NULL default '',
`email` varchar(30) NOT NULL default '',
`comment` text NOT NULL,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`gbno`)
) ENGINE=MyISAM ;
assuming the form validated successfully and i'm at the part where i'm adding the entry to the database, below are the codes on my controller relating to the insert query:
Code:
$datestring = "%Y:%m:%d %h:%i:%s";
$time = time();
$date = mdate($datestring, $time);
$insert_data = array(
'inc_no' => NULL ,
'name' => $_POST["name"] ,
'email' => $_POST["email"] ,
'comment' => $_POST["comment"] ,
'date' => $date
);
$this->db->insert('guestbook_table', $insert_data);