Welcome Guest, Not a member yet? Register   Sign In
Model Error... _parent_name
#1

[eluser]CreedFeed[/eluser]
I'm following the guide to create a model and using the Active Record Query to run an insert into my database... but I keep getting the following error:

Unknown column '_parent_name' in 'field list'

Code:

Code:
class Client extends Model
{
    var $id = '';
    var $name = '';
    var $address1 = '';
    var $address2 = '';
    var $city = '';
    var $state = '';
    var $zip = '';
    var $phone = '';
    var $fax = '';
    var $email = '';
    var $date_added = '';
    var $added_by = '';
    var $date_edited = '';
    var $edited_by = '';
    
    function Client()
    {
        parent::Model();
    }
    
    function insert()
    {
        $this->db->insert('clients', $this);
    }

I found another thread from late 2006 with the same issue but the answers were kind of vague and it looked as if previous posts had been edited since the posting of the topic so I didn't really understand the answer that was given.

Can anyone help? Why can't you simply pass in the actual object to run the insert? It seems to be automatically adding three fields to the object: _parent_name, _ci_scaffolding, _ci_scaff_table
#2

[eluser]coolfactor[/eluser]
Those fields would be inherited from the Model class. This is probably something that could be fixed, but in the meantime, just use an array instead.

Code:
class Client extend Model {
    var $data = array('id' => '',
                      'name' => ''
                      ... etc.
                      );
}

function insert() {
    $this->db->insert('clients', $this->data);
}




Theme © iAndrew 2016 - Forum software by © MyBB