DataMapper ORM

Add Model Path

Add Model Path is a static dynamic method that allows you to define alternative file locations for the model autoloader. When a model is requested the autoloader checks all defined paths for the existence of a models folder. If that exists, it will check if the request model file exists, and if so, it will be loaded.

Datamapper searches the following locations:

You can add model search paths to Datamapper manually using the Add Model Path static method:

// add the users, groups and admin modules to the model autoloader search path
Datamapper::add_model_path( array( APPPATH.'modules/users', APPPATH.'modules/groups', APPPATH.'modules/admin' ) );

Note that this is a global operation, you will have to do this only once per page request, for example in the controlller constructor.