jsonq icon indicating copy to clipboard operation
jsonq copied to clipboard

Can't get whereIn to work

Open tomkeysers opened this issue 4 years ago • 2 comments

I'm trying to filter on a key that returns an array of colours, but I can't get it to work. Example of data:

$result = Array
(
    [0] => Array
        (
            [Art nr] => 2094
        )

    [1] => Array
        (
            [Art nr] => 0480C
        )

    [2] => Array
        (
            [Art nr] => 1576
        )

    [3] => Array
        (
            [Art nr] => 2619
            [Colour (website)] => Array
                (
                    [0] => Brown
                )
        )

    [4] => Array
        (
            [Art nr] => 1449
        )

    [5] => Array
        (
            [Art nr] => 3252
        )

    [6] => Array
        (
            [Art nr] => 2618
            [Colour (website)] => Array
                (
                    [0] => Brown
                )
        )

    [7] => Array
        (
            [Art nr] => 3029
            [Colour (website)] => Array
                (
                    [0] => Brown
                )
        )
)

My code:

$jsonq = new Jsonq();
$jsonq->json(json_encode($result));
$res = $jsonq
	->whereIn("Brown", "Colour (website)")
	->get();
write_log($res);

But I get an empty array as a result. I also tried switching the key and value in the command, like whereIn("Colour (website)", "Brown"), but without result.

Another thing I tried is converting the colour field to json, so it becomes a 'flatter array' like this: [colour_website] => ["Brown"] but that also doesn't work.

What am I doing wrong?

tomkeysers avatar Jun 24 '20 15:06 tomkeysers

can you please give me the real data?

nahid avatar Jul 03 '20 19:07 nahid

Hi @nahid , the first part of my post, with the array data, is a snippet of the real data. The array keys Colour (website) is mainly what it's about.

tomkeysers avatar Jul 09 '20 11:07 tomkeysers