Welcome Guest, Not a member yet? Register   Sign In
How i can use model in other model?
#8

[eluser]jurosik[/eluser]
Maybe I should write more...

I had one big model with all functions, but now i need to make this model more comprendious, so i allocate my functions into tematic models. but functions have calls between models.

I need to load model once, and then just call them anywhere in model...

Code:
model1
   load model2 (model3, 4...)

function1() {

   model2->function2()

}

i have tried this:
Code:
class Data_model extends Model {

    function Data_model()
    {
        parent::Model();        
        $this->CI =& get_instance();
        $this->CI->load->model('main_model');
        $this->CI->load->model('file_model');
    }

...

$this->CI->main_model->getSomething($value);

But when i load file Data_model in Main_model (here is function 1 which i am calling from Data_model) it doesn't work
Code:
class Main_model extends Model {

    function Main_model()
    {
        parent::Model();
        $this->CI =& get_instance();
        $this->CI->load->model('data_model');
        $this->CI->load->model('file_model');
    }

    function getSomething($value)
    {
        return $value;
    }
}

mybe it's very complicated to explain...


Messages In This Thread
How i can use model in other model? - by El Forum - 12-30-2007, 06:09 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:32 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:39 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:46 AM
How i can use model in other model? - by El Forum - 12-30-2007, 07:55 AM
How i can use model in other model? - by El Forum - 01-05-2008, 01:02 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:08 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:19 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:34 PM
How i can use model in other model? - by El Forum - 01-05-2008, 01:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB