I am stucking in a code .I have 5 different Controllers
page in admin folder like controller_A.php
,controller_B.php
,controller_C.php
,controller_D.php
,controller_E.php
, Now I want to access method or function of 4 controller A ,B ,C ,D into Controller E method.
Please help me , how to call 4 different controller method into other controller.
Asked
Active
Viewed 107 times
1

Vivek Singh
- 2,453
- 1
- 14
- 27

Maneesh Sharma
- 63
- 1
- 12
-
You might need HMVC for that https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc – Aug 11 '16 at 05:21
-
did you check some other answer like http://stackoverflow.com/questions/14165895/how-to-load-a-controller-from-another-controller-in-codeigniter – Vivek Singh Aug 11 '16 at 05:24
-
Yes i have checked Vivek , i am able to access one controller data into another bt i want to access 4 different controller data into single controller. – Maneesh Sharma Aug 11 '16 at 05:27
-
[http://stackoverflow.com/a/38699894/6369494](http://stackoverflow.com/a/38699894/6369494) check my comment here this will help you – Tejas Mehta Aug 11 '16 at 05:35
-
Codeigniter is MVC which loading controllers with in controllers is not the MVC way how every as I have suggested up top HMVC better option. Because if you try some of the other answers when you try autoload some libraries you might run in to issue – Aug 11 '16 at 06:11
2 Answers
0
may be this will help to solve your problem. generallly , you can load other controller as
Load Controller inside your controller like
$this->load->library('../controllers/Your_controller');
then simply call the method
$this->Your_controller->functioname();

Tejas Mehta
- 791
- 1
- 6
- 15
-
Thanx but this will call only one controller , i want to call 4 different controllers – Maneesh Sharma Aug 13 '16 at 04:45
-
have you tried with `$this->load->library('../controllers/first_controller');` `$this->load->library('../controllers/second_controller');` `$this->load->library('../controllers/third_controller');` `$this->load->library('../controllers/fourth_controller');` – Tejas Mehta Aug 13 '16 at 11:09
0
You can try with below strategy:
require_once('controllers/controller_B.php');
$obj_b = new controller_B();
$obj_b->function_b();
require_once('controllers/controller_C.php');
$obj_c = new controller_C();
$obj_c->function_c();

Kartik Shah
- 107
- 3