In the process of upgrading from Codeigniter 2.2 to 3.1 we renamed all of the models. Now they are not loading unless I remake them with another name.
Looking at numerous other articles common issues are failing to load the model or typos in the names. I am not seeing either of these to be the case. There are several models who all have this issue, but a fix I found which is not ideal is making a new model with a new name. The first example is a model called PrpmsModel I can take everything in this file and make a new model called FooModel.php and just change the class name in the file to also be FooModel and then when I load it and make a call it works.
<?php
/**
* PRPMS - Model
**/
if (! defined('BASEPATH'))
exit('No direct script access allowed');
class PrpmsModel extends MY_Model
{
I took out the tail end but just to see top definition.
$this->load->model('PrpmsModel');
$employee = $this->PrpmsModel->fetchPRPMSbyEmployeeId(1, 1);
This does not work above.
<?php
/**
* Foo - Model
**/
if (! defined('BASEPATH'))
exit('No direct script access allowed');
class FooModel extends MY_Model
{
Copied all of PrpmsModel.php into FooModel.php
$this->load->model('FooModel');
$employee = $this->FooModel->fetchPRPMSbyEmployeeId(1, 1);
This above does work. The model used to be prpmsModel, so I just changed the case. The file name was also changed to match the PrpmsModel casing.
Naming conventions changed between CI 2.x and CI 3.x and are outlined in the 2.x->3.0 migration guide available HERE
with specific regard to models, keep in mind that in CI 3:
sales_model.php
is NOT OK, neither is SALES_MODEL.php
nor Sales_Model.php
. Sales_model.php
IS OK)Class Sales_model extends CI_Model { }
$this->load->model('sales_model');
IS OK, while $this->load->model('Sales_model');
, $this->load->model('Sales_Model');
or $this->load->model('SALES_MODEL');
are not)Make sure everything in your migrated codebase adheres to the above conventions and you should be fine. If not, some more code (and also error/debug logs) would be needed to help you debug.
Since you'll already be reviewing the 2.x->3.0 migration guide, take the time to review the whole document. A lot changed from 2.x to 3.x, so it definitely wouldn't hurt to make sure everything conforms to 3.x standards