I would look into using the cache! Start from here in the CakePHP
book:
http://book.cakephp.org/view/1193/Caching

Enjoy,
   John

On Feb 20, 2:22 pm, "Krissy Masters" <[email protected]>
wrote:
> Not sure why I only thought of this now.
>
> Any form: quick dummy function
>
> function edit() {
>
> If(!empty($this->data)) {
>
>        If($this->save());
>
>         // whatever
>        }
> $countries = $this->Model->_getCountries(); // returns list of countries
> $this->set(compact('countries'));
>
> }
>
> So you have a full list of countries in the form user can select from.
>
> $validate array() in model I have a function to check the country_id value
> and that function also uses _getCountries();
>
> public function checkCountryValues( $data, $field ){
>
> $valid = false;
>         if( !empty( $this->data[$this->alias][$field] ) ) {
>                 if ( array_key_exists($this->data[$this->alias][$field],
> $this->_getCountries() ) ){
>                         $valid = true;
>                 }
>         }
>         return $valid;
>
> }
>
> So I am essentially grabbing that data twice. How can I reuse that initial
> $countries throughout the whole process rather than grabbing the same data
> over and over?
> Might sounds trivial but some models might have 6 or more related models and
> then validating pulling all the same values used in the view / form it is
> just added work.
>
> Thanks,
> K

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to