on the server I can not load a model that is in another module in the HMVC, framework of the Codeigniter framework, I tried this way:
Class Contract extends MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('Contract_model', 'contract');
$this->load->model('register/customer_model', 'customer');
$this->load->model('register/daydue_model', 'due');
}
}
Structure
In the localhost works quietly, since the server is giving this error::
Message: Unable to locate the model you have specified: Daydue_model
When you uploading on server use casesensitive it does not create problem on localhost. your model name is incorrect.
Do it like this
$this->load->model('register/daydue_model', 'due');
And rename your model name to Daydue_model and check the class name same is the name of model like:
class Daydue_model extends CI_Model
Related
I searched for solutions , but all answers i found was outdated and don't helped me. So , there is my problem.
I'm trying to extend CI_Model core model class. I'm following the oficial guide
But it's not working.
Below is how i'm doing it:
Path/Filename of my class i want to create:
application/core/MY_Model.php
The content of MY_Model.php
class MY_Model extends CI_Model {
public function __construct()
{
parent::__construct();
}
}
And, this is how i'm trying to load it at my model file:
class Setor extends MY_Model { ....
The error message i'm getting:
Class 'MY_Model' not found in C:\wamp\www\agenda\application\models\Setor.php
I'm using Windows 10, php 5.5.12, CodeIgniter 3.0.6
After Hosting Php codeignitor website I Got a Error "Unable to locate the model you have specified: Common_model"
But Its Works in my local server
How I can solve this issue
I already change First letter of the model class name capitalized but no result
my model class
class Common_model extends CI_Model
{
}
and controller is
<?php
class Show extends CI_Controller
{ var $pageLimit = 6;
public function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->model('common/Common_model');
$this->load->helper('url');
$this->load->helper('form');
$this->load->helper('custom');
}
}
If you are are using Codeignitor 3 than make sure you file name also start with capital letter as:
Common_model.php
It's recommended to use your models inside the model folder not model/anyfolder
Codeignitor 3 Change Log User Manual
I hope Your model file structure is like
application
model
common
Common_model.php
File name should be Common_model.php.
Load in Controller should be
$this->load->model('common_model');
I always load it with the name only, this way
$this->load->model('Common_model');
Always the controller is on the same module (if you are using modules)
In my CI 2.2 project I want to make my parent controll with app's common functionality for use in all app and for this I create file :
application/libraries/N_Controller.php :
<?php
class N_Controller extends Controller
{
public function __construct()
{
parent::__construct();
}
But on first attempt to use it in file
application/controllers/admin/admin.php
<?php
class Admin extends N_Controller
{
public function __construct()
{
parent::__construct();
I got error:
PHP Fatal error: Class 'N_Controller' not found in /controllers/admin/admin.php on line 3, referer: http://local-ci22.com/admin/hostel/edit/15
I tried to add in application/config/autoload.php file :
$autoload['libraries'] = array( 'AppSmarty', 'AppUtils', 'N_Controller');
But it did not help. Which is the correct way ?
if you want to extend the functionality of a system class. you need to follow this recomendations.
place your extended class in /application/core, be sure that you name it exactly like the name and casing of the class created.
your class should extend from CI_Model or CI_Controller, depending on your needs.
wherever you implement your new class, be sure that you honor the same name casing from your extended class.
you should have configured the $config['subclass_prefix'] on /application/config/config.php. let's say in your case with the value 'N_'
what i can see from your code, you are not extending from CI_Controller and your path seems wrong.
Informative note: the /application/library is used to place classes and libraries from 3rd parties that won't fit into CI schemas.
I know there are other similar questions, but even after following all the syntax, this errror exists
I am using Codeigniter version 2.1.4 on wamp server, windows 7.
in application/core/ i have MY_Basedbclass.php starting with
abstract class MY_Basedbclass extends CI_Model
{
and trying to use it in my mode like
class Accounts_manager extends MY_Basedbclass
{
ending up with the error - Fatal error: Class 'MY_Basedbclass' not found in C:\wamp\www\party_app\server\application\models\accounts_manager.php
Please suggest what i am doing wrong. Thanks
EDIT - Addign a screen shot for the file structure sake
why you define your core model class as abstract class? after that you can only set core model class as MY_Model. this name get from subclass_prefix + class_name_you_want_to_over_write
define your core class like this:
class MY_Model extends CI_Model {
// your code
}
before that assured in your config.php file you set $config['subclass_prefix'] = to MY_
config file address: application > config > config.php
I have a project based on codeigniter. I already have a model that extends some CI_Model class. class Playermodel extends CI_Model . I need to import Playermodel in one of my classes so that I can easily access database without hard coding the connection with php.
However this CI_Model class is making me trouble coz I cannot really find a file with CI_Model class. Also when I import it I get internal server error 503.
What should I do in this case and where can I find this CI_Model class?
Thanks
Your models will typically be loaded and called from within your controller functions. To load a model you will use the following function:
$this->load->model('Model_name')
The DB connection settings are stored in application/config/database.php you dont need to hardcord it int your files. Then to connect to database
$this->load->database();
Read the revelant user_guide model database