Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-1051

"$in needs an array" error when running find() against MongoDB 2.6

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: pecl-mongo
    • Labels:
    • # Replies:
      10
    • Last comment by Customer:
      false

      Description

      This works in mongodb 2.4.9, but not in 2.6.0-rc2:

      $a = array('_id' => array( '$in' => array_values($ids) ) ); 
      var_dump($a);
      $cursor2 = $data->find( $a );

      returns:

      Type: MongoCursorException
      Code: 17287
      Message: Can't canonicalize query: BadValue $in needs an array

      Output from var_dump:

      array(1) {
        ["_id"]=>
        array(1) {
          ["$in"]=>
          array(3) {
            [0]=>
            object(MongoId)#57 (1) {
              ["$id"]=>
              string(24) "52214d60012f8aab278eacb6"
            }
            [1]=>
            object(MongoId)#58 (1) {
              ["$id"]=>
              string(24) "52214d60012f8aab278eaca8"
            }
            [2]=>
            object(MongoId)#59 (1) {
              ["$id"]=>
              string(24) "52214d60012f8aab278eaca7"
            }
         }
      }
      }

      Apologize right away if this is a php driver bug, I wasn't sure what causes this issue.

      Thank you!

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since reply:
                  3 years, 33 weeks, 1 day ago
                  Date of 1st Reply: