jamierumbelow / codeigniter-base-model

⛔️DEPRECATED CodeIgniter base CRUD model to remove repetition and increase productivity
MIT License
1.05k stars 479 forks source link

Three levels relationship #227

Open zahidmuhammadzaki opened 8 years ago

zahidmuhammadzaki commented 8 years ago

How i can relate 3 models in single call?

Just in case, i have 3 models:

Can i call this in 1 call like this?

$this->market_model->with(array(
  'market_tree' => array(
    'with' => market_tree_pc
)))->get_all();
dadenewyyt commented 8 years ago

I guess you need to chain with the second text on the array like a method call with the other model.

with()-> ...->with() On May 23, 2016 2:04 AM, "Zahid" notifications@github.com wrote:

How i can relate 3 models in single call?

Just in case, i have 3 models:

  • Market_model => Market_tree_model => Market_tree_pc_model

Can i call this in 1 call like this?

$this->market_model->with('market_tree' => array( 'with' => market_tree_pc ))->get_all();

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jamierumbelow/codeigniter-base-model/issues/227

dadenewyyt commented 8 years ago

simply chain then with remove the arrays On May 23, 2016 4:53 PM, dadenew.yyt@gmail.com wrote:

I guess you need to chain with the second text on the array like a method call with the other model.

with()-> ...->with() On May 23, 2016 2:04 AM, "Zahid" notifications@github.com wrote:

How i can relate 3 models in single call?

Just in case, i have 3 models:

Can i call this in 1 call like this?

$this->market_model->with('market_tree' => array( 'with' => market_tree_pc ))->get_all();

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jamierumbelow/codeigniter-base-model/issues/227

zahidmuhammadzaki commented 8 years ago

@dadenewyyt

Do you mean like this? $this->market_model->with('market_tree')->with('market_tree_pc')->get_all();

But, it only works if

market_model (has many) => market_tree; and market_model (has many) => market_tree_pc;

What i mean is market_model (has many) => market_tree (has_many) => market_tree_pc

and i want call tree of this in single call like below, $this->market_model->with(array( 'market_tree' => array( 'with' => market_tree_pc )))->get_all();

dadenewyyt commented 8 years ago

Yes Zakir. To use the my Model you have to follow the rules With take a has many or one to one relationship to refer as with. So if you want to give a new meaning to with - you should modify it in my_model class = may be a new name with_new .

On Tue, May 24, 2016 at 11:48 AM, Zahid notifications@github.com wrote:

@dadenewyyt https://github.com/dadenewyyt

Do you mean like this?

$this->market_model->with('market_tree')->with('market_tree_pc')->get_all();

But, it only works if

market_model (has many) => market_tree;

and

market_model (has many) => market_tree_pc;

What i mean is

market_model (has many) => market_tree (has_many) => market_tree_pc

and i want call tree of this in single call like below,

$this->market_model->with(array( 'market_tree' => array( 'with' => market_tree_pc )))->get_all();

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/jamierumbelow/codeigniter-base-model/issues/227#issuecomment-221205265

Daniel Adenew YYT Software Development www.yytsoftware.com

zahidmuhammadzaki commented 8 years ago

My name is zahid :D

I see. But i hope it can be the new feature in the new update..

Thank you :)