In CakePHP the model class is used as an interface to the database -
the actual data you get back is always associative arrays.  If you
have a fullname() function that perhaps concatenates your first and
surnames, you could have

class YourModel
{
  function fullname( $id ){
    // get the data
    $model_data = $this->read(null, $id);
    // return the calculated full name
    return $model_data[$this->name]['firstname'].' '.$model_data[$this-
>name]['surname'];
  }
}

Or, you could retrieve the model data in your controller, and have the
model fullname() function expect the model data (and just perform the
concatenation).  Or finally, you could have a afterFind() callback in
your model, to automatically create the 'fullname' key on your
retrieved data.

Having data retrieved as simple data arrays rather than models is good
for performance, and if you write your model functions appropriately
can still be quite easy to use.  I believe that being able to actually
retrieve class instances rather than data arrays is planned for
CakePHP 2.0 (which will be some time away).


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to