Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use models without database on CakePHP and have associations?

Tags:

cakephp

I've got the field country_id in one of my models and instead of creating a countries table which contains a list of countries that doesn't change, what's the best approach to this?

I'm thinking about using a model without a database table but I don't know how to implement this.

Please help. Thanks in advance!

like image 919
Vibedude Avatar asked Aug 03 '11 09:08

Vibedude


1 Answers

you can totaly use the no table syntax:

class ModelWithoutTable extends AppModel
{
    var $useTable = false;
}

to have this Country Model tableless, but you need to mock a data source (i.e. XML,YAML,PHP Array and etc) for the countries data.

Hope this helps.

like image 103
Balchev Avatar answered Oct 13 '22 17:10

Balchev