01-23-2009, 01:43 PM
[eluser]juddmuir[/eluser]
I've hit a problem using models and attempting to update the database.
If your model is more than just a representation of a database table, then you may have variables in your model that do not exist in the database. So when you come to e.g. update the database using
function update_entry()
{
$this->db->update('entries', $this, array('id' => $this->id));
}
an error is generated if you have a variable that doesn't map to a field. Is the solution to generate TWO objects: one that is the model that you're using, and the other that is the data-model to pass to the db->update function?
I've hit a problem using models and attempting to update the database.
If your model is more than just a representation of a database table, then you may have variables in your model that do not exist in the database. So when you come to e.g. update the database using
function update_entry()
{
$this->db->update('entries', $this, array('id' => $this->id));
}
an error is generated if you have a variable that doesn't map to a field. Is the solution to generate TWO objects: one that is the model that you're using, and the other that is the data-model to pass to the db->update function?