Skip to content
Advertisement

Make A Dynamical Model With Join CodeIgniter

I asked this question yesterday but it got deleted because admins said it got similar question with other post but when I check it there it doesn’t have the same problem with me, so ill ask again and hope that admin can understand.

I have this model in CodeIgniter:

JavaScript

It has a parameter that I can use dynamically (I mean I can use this model with different value based on controller) – right? So when I use controller it will be like this:

JavaScript

I can set the value of select whatever I want, I can set the value of where to whatever I want, etc

But there is a problem: when I set the value of join, it doesn’t work like where and select.

I get this error:

An uncaught Exception was encountered
Type: ArgumentCountError

Message: Too few arguments to function CI_DB_query_builder::join(), 1 passed in C:laragonwwwonlineformapplicationmodelsModel_online.php on line 71 and at least 2 expected

Filename: C:laragonwwwonlineformsystemdatabaseDB_query_builder.php

Line Number: 526

My question is how to set this array value in so I can use it in the model inside the variable join

So my model can be used for many situation that need a join (single or multiple join whatever)

JavaScript

I don’t want make model like this, because it means it only can be used by 4 join, when I need a 3/2/1 join I make model again.

JavaScript

Sorry I explain a lot, because I can’t find solution of this, and I don’t want admin delete my unanswered post 🙁

Please don’t delete this admin let people help me :’)

Advertisement

Answer

Use multidimensional array.I think this will works for you.

JavaScript

and use this in model side like this.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement