October 6th, 2007
In the Code Igniter Models documentation it details the Active Record insert, which builds the insert around your class variables, allowing you to do this:
$this->title = $_POST['title']; $this->content = $_POST['content']; $this->date = time(); $this->db->insert('entries', $this);
However there’s a bug: it doesn’t distinguish against private class variables, leaving you with errors like this:
error, no fields in database named ‘_parent_name’ ,’_ci_scaffolding’ , and ‘_ci_scaff_table’
These private class variables (denoted by the underscore) are inherited from the base Model class, but can be stripped out by editing system/database/DB_active_rec.php function _object_to_array:
if ( ! is_object($val) AND ! is_array($val) AND substr($key, 0, 1) != '_');