Welcome Guest, Not a member yet? Register   Sign In
how to call a function of another class
#11

[eluser]echoDreamz[/eluser]
[quote author="InsiteFX" date="1286188735"]You can change the MY_ prefix to what ever you like!
It doe's not have to be MY_

InsiteFX[/quote]

Uh maybe you should practice what you preach and re-read my post above...
Quote:We have different prefixes for our files vs customer specific files libraries / helpers.

If we have multiple prefixes IE: CUSTOMER_ and OUR_ CI can only support 1. So we choose to support the CUSTOMER_ prefix and use the autoload to aid in loading OUR_ prefixed classes.
#12

[eluser]InsiteFX[/eluser]
Quote:Uh maybe you should practice what you preach and re-read my post above…

So why did you post this as a bug when it is a development design issue?

InsiteFX
#13

[eluser]echoDreamz[/eluser]
[quote author="InsiteFX" date="1286212273"]
Quote:Uh maybe you should practice what you preach and re-read my post above…

So why did you post this as a bug when it is a development design issue?

InsiteFX[/quote]

Not my topic????
#14

[eluser]Sumon[/eluser]
The situation is: i have a common function
Code:
function is_it_valid_member($id){
  //do some query and return true or false
}
i need to call this function from different controllers like amdin.php, member.php, transaction.php and so on.
how shall i do it?
I think the best answer of my question is write the function as follows and create a file inside helper. call this function directly from controller, model or views.

Code:
function is_it_valid_member($id){
  $this->CI =& get_instance();
  $this->CI->load->database();
  //do some query and return true or false
}

if someone of you have better solution please share. because i need this feature repeatedly in every projects.
#15

[eluser]OliverHR[/eluser]
[quote author="dstegelman" date="1286083537"]Why are you calling a function from a controller inside of a controller. I can't think of many situations where you need to do this. if you need commonly shared data, you should probably be using a model to get it instead.[/quote]

[quote author="Dennis Rasmussen" date="1286103393"]Listen to the guys giving you help.
If you need to run some code in more than one controller then write the code in a library or even a model for reuse.
You don't call methods from another controller, that kinda makes no sense.[/quote]

Heard about HMVC?

https://bitbucket.org/wiredesignz/codeig.../wiki/Home
#16

[eluser]Dennis Rasmussen[/eluser]
[quote author="OliverHR" date="1313291197"][quote author="dstegelman" date="1286083537"]Why are you calling a function from a controller inside of a controller. I can't think of many situations where you need to do this. if you need commonly shared data, you should probably be using a model to get it instead.[/quote]

[quote author="Dennis Rasmussen" date="1286103393"]Listen to the guys giving you help.
If you need to run some code in more than one controller then write the code in a library or even a model for reuse.
You don't call methods from another controller, that kinda makes no sense.[/quote]

Heard about HMVC?

https://bitbucket.org/wiredesignz/codeig.../wiki/Home[/quote]

My quote is taken out of context as this guy was talking about this elsewhere before making this topic. And what does my quote have to do with not knowing HMVC? Even with HMVC the model/controllers are libraries, which I also state in my quote (use a library).
#17

[eluser]InsiteFX[/eluser]
Another this people do not understand about the MY_Controller is that you can
name it anything you like in the Class!
Code:
Class Any_Thing extends CI_Controller {

    public function __contruct()
    {
        parent::__construct();
    }
}
It just has to be saved as a MY_Controller.php

InsiteFX
#18

[eluser]nikes[/eluser]
Why are you currently calling a purpose from the controller within of the controller. I cannot think about the quantity of scenarios especially where you must make an make an effort to do this. at any time you need usually shared data, you need to possibly be utilizing a design to acquire it instead.
#19

[eluser]OliverHR[/eluser]
Quote:My quote is taken out of context as this guy was talking about this elsewhere before making this topic. And what does my quote have to do with not knowing HMVC? Even with HMVC the model/controllers are libraries, which I also state in my quote (use a library).

ok[
#20

[eluser]Unknown[/eluser]
How to in 2.0.2?




Theme © iAndrew 2016 - Forum software by © MyBB