Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get whereIn to work #55

Open
tomkeysers opened this issue Jun 24, 2020 · 2 comments
Open

Can't get whereIn to work #55

tomkeysers opened this issue Jun 24, 2020 · 2 comments

Comments

@tomkeysers
Copy link

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?

@nahid
Copy link
Owner

nahid commented Jul 3, 2020

can you please give me the real data?

@tomkeysers
Copy link
Author

tomkeysers commented Jul 9, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants