[eluser]alexmiller[/eluser]
I am slowly getting to grips with CI.
I have a model for people. It has fields for first_name, last_name etc. So I have set up person_model as a CI model eg. (pseudo-code)
Code:
class person_model extends Model
{
function getPersonById($id)
{
$Q = $this->db->get_where('people',array ('user_id'=>$id),1);
return $Q->row();
}
}
I can then call this in my controller:
Code:
$person = $this->person_model->getPersonById(1);
But here's the question:
I want to be able to do things like:
Code:
echo $person->possessive(); // adds 's to end of first_name
echo $person->full_name(); // concats first_name and last_name
I know I can get an object out of my database result, but how can I add methods to that object? More importantly, am I circumventing the MVC structure here? In a way, I am creating another model layer.