Created
March 29, 2011 15:00
-
-
Save yuya-matsushima/892496 to your computer and use it in GitHub Desktop.
MY_Controller.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MY_Controller extends CI_Controller | |
{ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
// The easy way to use model in controller | |
// http://elliotscode.com/2011/03/28/codeigniter-my-controller/ | |
protected function model($name) | |
{ | |
$name = $name . '_model'; | |
if( ! isset($this->{$name})) | |
{ | |
$this->load->model($name); | |
} | |
return $this->{$name}; | |
} | |
//The easy way to call view in controller | |
protected function view($name, $data = array(), $return = FALSE) | |
{ | |
$name = $name . '_view'; | |
return $this->load->view($name, $data, $return); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment