Reputation: 685
I want to load a controller function from another controller function using codeigniter. What is the suitable way to do this so when call it url should be changed also.
Upvotes: 3
Views: 9986
Reputation: 1
yes you can (for version 2)
load like this below inside your controller
$this->load->library('../controllers/whathever');
and call the following method:
$this->whathever->functioname();
Upvotes: 0
Reputation: 38672
No You cant do it.
What you have to do it is create that function in model and call it through your controllers. So it will work fine.
Ex
In Model
function get_id()
{
//some argument
}
In controller 1
$this->Model_name->get_id()
In controller 2
$this->Model_name->get_id()
Upvotes: 3