Reputation: 461
I have a list of countries and ccodes in a database. I would like to be able to put that data in to an array in the AppController so I can use it via $this->countries in my other controllers. A kind of $this->App->query() if you like. How can I do this please :) Thank you in advance.
Upvotes: 0
Views: 89
Reputation: 5429
Why don't you just load the countries with a model?
You could use the model in every controller (at least I think).
This should work then: $this->Country->find('all')
If you don't want to write this every time you could also move it into a helper.
Upvotes: 0
Reputation:
In your AppController put:
public $uses = array('Country'); //list of models
public $countries = $this->Country->find('all');
Upvotes: 1