I'm using CI2. with PHP 5.3

I simply began to make use of “Datamapper ORM” which is excellent!! however is really a one large problem concerning the classes’ names

I've got a database table known as “users” so my dm model is “user” as well as I've got a controller with similar title “user”?

so while using “user” model inside the “user” controller is imposible!!

what's the easiest method to solve this issue?

Thank You


Among the disadvantages in CodeIgniter is you cannot title a controller, model or library exactly the same factor. This really is mainly a PHP problem as clearly you can't title anything exactly the same, but it may be prevented in 2 ways.

  1. PHP Namespaces - no can perform, they're PHP 5.3 only and 90% from the community would start when they were implemented.
  2. Controller Prefixes - This really is something I would like to add, but... well it might break stuff for everybody. We'll have to hang about until 2.1 a minimum of for something new that large.

For the time being all I'm able to recommend is that you simply title your models and libraries carefully.

Controller - Customers
Library - User
Model - User_model User_m

It's annoying, but one of individuals things for the time being.

so while using “user” model inside the “user” controller is imposible!!

Umm no it is not, you have to look into the UserGuide more carefully )

You might give your model a title apart from what it's orginaly understood to be:

If you'd like your model designated to another object title you are able to specify it through the second parameter of the loading function:

$this->load->model('Model_name', 'fubar');    

All that you should do is improve your controller file title and sophistication title to "Customers". You don't have to improve your model title.

controller: customers
model: user
db table: customers

Have a look in the Datamapper docs.