[eluser]momsenmeister[/eluser]
Hi,
my model classes look like this:
Code:
class User extends Model
{
var $id = '';
var $firstname = '';
var $surname = '';
function update_entry()
{
$this->firstname = $this->input->post('firstname');
$this->surname = $this->input->post('surname');
$this->db->where('id', $this->id);
$this->db->update('user', $this);
}
}
For updating data I use a function like update_entry().
Like this I can always just use
Code:
$this->user->firstname
in my views, for example.
But my problem is: If my class variables don't exactly match my database table columns, I can't use
Code:
$this->db->update('user', $this);
or I get an exception
Quote:Unknown column in field list.
I try to avoid building a specific array each time I want to update some data.
Is there any way to just ignore columns, that don't exist in my database table?
For example, I might have an extra variable called "initials" in my model to use
Code:
$this->user->initials
in my views, but I might not need an extra column in my database table for it.
Any solution? Any best practices?
Thx!