Posts: 48
Threads: 15
Joined: Jul 2020
Reputation:
0
Is it possible to extend CodeIgniter's model to allow parameters to be passed to the constructor? I have four models that are almost identical. If there were a way to pass the table name and the allowed fields array to the model via the constructor, I could eliminate a bunch of code.
Posts: 45
Threads: 6
Joined: Sep 2020
Reputation:
-1
Are you uzing CI4 or still CI3??
Posts: 4,363
Threads: 101
Joined: Oct 2014
Reputation:
146
That would require you to update the system/model and that is not recommended you should
never change a system file.
You could extended say the BaseModel, setup your Constructor and then extend all your models
form the BaseModel. In the BaseModel do not use the parent__construct() only in the model that
you extend from the BaseModel.
BaseModel extends Model
All your Models extend BaseModel
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )