I am using CI2.0 with PHP 5.3
I just started to use “Datamapper ORM” and it is excellent!! however their is a one big problem regarding the classes’ names
I have a database table called “users” so my dm model is “user” and also I have a controller with the same name “user”?
so using the “user” model within the “user” controller is imposible!!
what is the best way to solve this problem?
Many Thanks
best regards
so using the “user” model within the “user” controller is imposible!!
Umm no it isn't, you need to check the UserGuide more carefully ;)
You may give your model a name other than what it is orginaly defined as:
If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:
$this->load->model('Model_name', 'fubar');
$this->fubar->function();
One of the drawbacks in CodeIgniter is that you cannot name a controller, model or library the same thing. This is mainly a PHP issue as obviously you cannot name anything the same, but it can be avoided in two ways.
For now all I can recommend is you name your models and libraries carefully.
Controller - Users
Library - User
Model - User_model | User_m
It's annoying, but just one of those things for now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With