Hi people, I want to report a problem that codeigniter 4.0.1 is having, I am currently working with a small consultation so that making it an exit situation to work. As you can see, I have some values that are sent through the query constructor.
You can consult in documentation the following valid line to work with:
[b]$builder->whereIn()[/b]
Code:
$names = ['Frank', 'Todd', 'James'];
$builder->whereIn('username', $names);
// Produces: WHERE username IN ('Frank', 'Todd', 'James')
In my case I want to make a query from it, performing similar actions, in which I carry out the sending of information as follows in text mode:
Code:
$listeeed = [1,129,122,123,124,125,126,127,128,130,120];
$Aquery->whereIn('id' , $listeeed );
The consultation from it is fully satisfactory.
Now we put something to the real world on a general level:
Code:
// print_r($loadDataList);// result [0] => 1 [1] => 129 [2] => 122 [3] => 123 [4] => 124 [5] => 125 [6] => 126 [7] => 127 [8] => 128 [9] => 130 [10] => 120
$josns = json_encode($loadDataList);
// print_r($josns); // this is result from var from here [1,129,122,123,124,125,126,127,128,130,120];
$listeeed = $josns;
$Aquery->whereIn('id' , $listeeed );
En lo siguiente como veran el framework presenta problema de la siguiente indole:
InvalidArgumentException
whereIn() expects $values to be of type array or closure
Code:
line 1026 throw new \InvalidArgumentException(sprintf('%s() expects $values to be of type array or closure', debug_backtrace(0, 2)[1]['function']));
I would appreciate it if you would give me information on how to get out of this situation, I find it strange because the sending of information is fine in string mode, I do not see the need to make more spaghetti code in something as primitive as a request for data from a query, unless you have to chat with some for cycle, since I am already waiting for your answers.
Update solve
I a thousand apologies people, something as cuckold as a null response because as the call was made from a function this was not sent, it is possible to clarify the bizarre situation:
Code:
function getA($josns = "")
{
...
}
print_r(getA( ));//here is this problem, :)
this raises the problem, I apologize, but I hope you have left it for our friends in case a similar situation arises.
Is very stupid a solution here:
Code:
print_r(getA($listeeed));