Welcome Guest, Not a member yet? Register   Sign In
call one of the method from another class
#1

[eluser]Uresh Patel[/eluser]
Respected,

I have two controllers.I want to call one of the method from one class.
Below both class are different controller files
E.g:
Code:
class User extends CI_Controller {

             function index(){
                 //code
             }

              function list(){
                   //i want to call class 'Blog.Add' method....
             }
}


  class Blog extends CI_Controller {

         function index(){
            //code
         }

         function Add(){
              //code
         }
}
Please suggest good way to do so ....
#2

[eluser]Otemu[/eluser]
Hi,

The best way to do something like this is either create a library or helper.

Also check out this excellent article CodeIgniter Base Classes: Keeping it DRY.

Hope that helps
#3

[eluser]Uresh Patel[/eluser]
HI,

Thank you for reply.But i am looking forward to have a proper solution.i have foggy idea but not clear with it.
We can create instance or can we do like language "C++" using friend function using that access modifier ?????

[quote author="Otemu" date="1366624431"]Hi,

The best way to do something like this is either create a library or helper.

Also check out this excellent article CodeIgniter Base Classes: Keeping it DRY.

Hope that helps[/quote]
#4

[eluser]jairoh_[/eluser]
do not use the controller. the proper way is to use model or library or helper. it depends. tell us the purpose of the add function.




Theme © iAndrew 2016 - Forum software by © MyBB