Codeigniter Load Multiple Models
Codeigniter Load Multiple Models– There is no limitation to load models in controller function, you can load multiple Models in same function. Here in this tutorial we are going to explain how you can load multiple models in a controller function.
Codeigniter Load Multiple Models In Controller Function Example
Multiple models can be loaded simply as below-
Codeigniter Load Multiple Models Example:
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Users extends CI_Controller { function __contruct() { parent::__construct(); $this->load->model('users'); $this->load->model('profile'); $this->load->model('logs'); } function seeAllUserData() { $data['users'] = $this->users->getAllUsers(); $data['profiles'] = $this->profile->getAllProfiles(); $data['logs'] = $this->profile->getAllLogs(); $this->load->view('my_view', $data); } } |
Advertisements