In the model:
$this->myFields = array('field_one, 'field_two', 'and_some_other');
public function modifyRequiredFields($additionalFields) {
array_push($this->myFields, $additionalFields);
return $this->myFields;
}
In the controller:
$this->ModelName->find('all', array('fields' => $this->ModelName-
>modifyRequiredFields(array('i_also_need_this', 'and_this'));
... or ...
if it's a "standard" find()
$this->ModelName->find('all', array('fields' => $this->ModelName-
>myFields));
On Sep 26, 3:14 pm, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> Just wondering if anyone has an opinion or fact about this.
>
> When pulling model data, keep it simple so Users controller getting straight
> info from Users database.
> Users table has 15 fields.
>
> You may only need 5 fields data and in another case you may need all 15
> fields.
>
> Is it best to specify the fields you need always?
> I guess the size of the data in the fields will make a difference.
> I am just thinking in regards to my app where i need a few fields, then i
> need all fields does it take more time to process a detailed request when
> you specify each individual field when you need info from 10 fields as
> opposed to *just and get them all.
>
> What is best practise? Or in this case its more of a try both and see what
> works best for each app?
>
> Thanks
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment