CodeIgniter Forums
Passing config params to the model? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Passing config params to the model? (/showthread.php?tid=77561)



Passing config params to the model? - blaasvaer - 09-17-2020

Hi,

I'm trying to pass in config parameters to the model on initialization. But, I can't seem to be able to do so, as I get this error:

Code:
Argument 1 passed to CodeIgniter\Model::__construct() must be an instance of CodeIgniter\Database\ConnectionInterface or null, array given, called in /Applications/MAMP/htdocs/ … /app/Controllers/Api.php on line 47

Now, what seems to be more frustrating is the fact that I have absolutely no clue WHERE to look in the docs for the syntax used to set model and pass in parameters. Now, the docs do not seem to be 'designed' for being used as a reference for situations like this. What I'm looking for is something like this:

Code:
$model = new YaddaYaddaModel( $my_config_for_the_model_here );


I've been trawling the docs for it but have had no 'luck' (yeah, that's what it actually takes ; ) ) finding it so far …