Get data arguments |
Hi, today I tried to follow the manual, in order to get data from the form, and did not quite understand how to correctly pass the parameter.
In my controller: PHP Code: $model->setParam([ When I send 2 arguments in my model: PHP Code: public function setParam($firstParam, $secondParam) { When I send 1 argument in my model, get "operand should contain 1 column(s)"... PHP Code: public function setParam($firstParam) { Looking inside print_r($firstParam); getting Array ( [firstParam] => 67545647f [secondParam] => 654547547554d ) Tell me please what I missed. Thanks.
You are calling your model method incorrectly.
Your setParam method has two conflicting signatures - one with a single parameter and one with two. Neither of them expects an array, just values. Your call to the method passes an array of parameters as the only parameter. Read your error message! (06-08-2018, 08:48 AM)ciadmin Wrote: You are calling your model method incorrectly. I noticed this when browsing and if I take them like this: PHP Code: $model->setParam([ But I wanted to learn how to correctly pass multiple values in CI4, because I'm not experienced ( Thanks for the answer!
There's nothing special about passing arguments to php functions/methods.
Read this: PHP - Function arguments What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(06-09-2018, 09:08 AM)InsiteFX Wrote: There's nothing special about passing arguments to php functions/methods. Thanks! I watched the controller in @lonnieezell "simple-forums" how is the information from the input fields transmitted there, but did not pay attention to getting the arguments to the model... |
Welcome Guest, Not a member yet? Register Sign In |