Welcome Guest, Not a member yet? Register   Sign In
using $this->load->model on Modular Extensions fails
#1

[eluser]moksahero[/eluser]
Hello,

I'm having trouble loading model using Modular Extensions.

The way I was trying was to use the first letter capital as:

$this->load->model('Customer_model')

this

modules_find function at line:130 in modular_helper.php doesn't include lower case string so that this fails and the follwing error

Code:
An Error Was Encountered

Unable to locate the requested file: ../system/application/models/admin/Customer_model.php

Is there a way to use class name with capital as suggested in CI user guide?

Thanks
#2

[eluser]wiredesignz[/eluser]
Model class names must be Capitalised, but file names must be lowercase as suggested in the CI user guide.
#3

[eluser]moksahero[/eluser]
In the user guide:

http://ellislab.com/codeigniter/user-gui...odels.html

under "Loading a Model" section model names with first letter being capital is used. for $this->Model_name->function(). This has been the way I have loaded and called all model related functions and I expected Modular Extensions to behave the same.

Am I missing something??
#4

[eluser]Jilani Jidni[/eluser]
[quote author="moksahero" date="1218719971"]In the user guide:

http://ellislab.com/codeigniter/user-gui...odels.html

under "Loading a Model" section model names with first letter being capital is used. for $this->Model_name->function(). This has been the way I have loaded and called all model related functions and I expected Modular Extensions to behave the same.

Am I missing something??[/quote]

You are in right track. please check what is your file name. if your model class name Customer_model then file name should be customer_model.php.

or check it into the manual

If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:

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

$this->fubar->function();
]

hope this will help you.
#5

[eluser]moksahero[/eluser]
The problem is that when I use :

$this->load->model('Customer_model');

ME looks for Customer_model.php not customer_model.php in the directory.

I saw the piece of code in ME that was not using lower case for file names and I started fixing it but I thought better to involve community with it.

Thanks
#6

[eluser]wiredesignz[/eluser]
ME checks for both lowercase filenames (customer_model.php) and capitalised filenames (Customer_model.php) in modules_find() method.

However you must use lowercase object names when loading and accessing them.
Code:
$this->load->model('customer_model');

$this->customer_model->get();

// or you can use an alias as per the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB