Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

load model from folder in codeigniter

I am using codeigniter and handing admin side and users side separately. now i have model which is in admin folder and i want to call in controller of users. but when i am trying to load model from admin folder

$this->load->model('admin/myinterest_model');

$data['myInterest'] = $this->myinterest_model->selectResult('user',  $this->session->userdata['Id']);

it shows following error

Message: Undefined property: Users::$myinterest_model
Filename: controllers/users.php

Please guide me how to load model from admin

like image 807
Zeeshan Avatar asked Nov 28 '22 01:11

Zeeshan


2 Answers

$this->load->model('admin/myinterest_model' , 'myinterest');

The second parameter (optional) is used to call the method.

ex:

$this->myinterest->get_users();
like image 196
user3460632 Avatar answered Dec 05 '22 22:12

user3460632


try this call constructor in controller and load model into it

function __construct()
    {
        // Initialization of class
        parent::__construct();

        // load the model
        $this->load->model('admin/myinterest_model');
    }
like image 40
Dexter Avatar answered Dec 05 '22 23:12

Dexter