A
A
alex-prog2017-07-30 21:26:53
MongoDB
alex-prog, 2017-07-30 21:26:53

Exception: and needs an array. Where is the mistake?

Good day.
Something incomprehensible is going on ...
The request to the monge looks like this:

Array
(
    [$and] => Array
        (
            [1] => Array
                (
                    [$or] => Array
                        (
                            [0] => Array
                                (
                                    [stateId] => 11
                                )

                        )

                )

        )

)

It gives an error, such as not an array, but what is it then? I put an index to the array to group requests.
exception: and needs an array
Now the most interesting thing, change the key "1" to "0" and everything is OK, no errors.
Array
(
    [$and] => Array
        (
            [0] => Array
                (
                    [$or] => Array
                        (
                            [0] => Array
                                (
                                    [stateId] => 11
                                )

                        )

                )

        )

)

I dug a little and realized that the numbering cannot start with "1", if there is no zero element, an error occurs, such as not an array. Into bullshit...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question