Load Model in subdirectory (3 level) |
[eluser]csotelo[/eluser]
Hello, I have the following structure in the Models folder -Models/ --admin/ ---quotes/ ----product_model.php --web/ The problem is I want to load the model "product_model" in quotes folder, but it shows me the error: $this->load->model('admin/quotes/product_model'); Quote:Unable to locate the model you have specified: product_model But when I change the file position: -Models/ --admin/ ---product_model.php --web/ ....functioning properly Only accepts 2 levels of load? It is possible to fix this? I hope your help.
[eluser]CroNiX[/eluser]
I know there is a limitation for controllers but didn't realize it affected models as well. Then again, I've never needed to use more than one level down.
[eluser]Fireclave[/eluser]
Look in the Loader.php in the Core folder. I Think it should works with 3 or more Levels. Strrpos finds the last matching, so it is not important how many Levels you have !? You could echo the path to see what happen (Line 144) Code: // Is the model in a sub-folder? If so, parse out the filename and path. Then the Path will be loaded(Line 194) Quote: require_once($mod_path.'models/'.$path.$model.EXT);
[eluser]csotelo[/eluser]
returns: application/models/admin/quotes/Product_model.php
[eluser]J. Pavel Espinal[/eluser]
Would it be the 'P' instead of 'p' in Product_model.php ?
[eluser]Glazz[/eluser]
I have tested it and it works. Folders: http://dl.dropbox.com/u/19002464/teste.png Model code for test: Code: <?php Try to use $this->load->model('your/folders/here/Product_model'); and then $this->Product_model->your_function_here(); In windows should work with product_model and Product_model it doesn't matter if it is upper case or not, but in unix systems it fails i guess.
[eluser]csotelo[/eluser]
Hi, I found the problem, I'm calling model with an alias: $this->load->model('admin/quotes/product_model', 'exec_model'); But when I remove the alias, it works. But why? I need to enter an alias, what is my mistake?
[eluser]Glazz[/eluser]
[quote author="csotelo" date="1337004396"]Hi, I found the problem, I'm calling model with an alias: $this->load->model('admin/quotes/product_model', 'exec_model'); But when I remove the alias, it works. But why? I need to enter an alias, what is my mistake?[/quote] It works fine for me, i tested with my previous test code, and added the alias as you are using, and it worked just fine. Are you on Windows or Linux ?
[eluser]Glazz[/eluser]
It should work, try installing a fresh copy of CodeIgniter an try to load a model like you are doing know. I can't figure it out, since it works just fine for me, with or without "alias". |
Welcome Guest, Not a member yet? Register Sign In |