views:

48

answers:

2

I can force to inlcude one model by

Yii::import("application.models.modelName", true);

What should I do to include all models from models directory?

Line:

Yii::import("application.models.*", true);

doesn't work becouse yii import only when there is need to use it.

A: 

Really, why would you want to import it except to use them?

Autoloading php feature is priceless :)

toninoj
A: 

Yii can't do that. Importing is pretty lightweight compared to real inclusion, but if you must accomplish that, here's a snippet:

foreach(glob(Yii::getPathOfAlias('application.models').'/*.php') as $script) {
   require $script;
}

I don't doubt there are cases when this approach is the best, but you really have to make sure it is in your scenario.

pestaa