php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76108 error in build filter with array
Submitted: 2018-03-17 07:43 UTC Modified: 2018-03-17 10:12 UTC
From: 860760361 at qq dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.28 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: 860760361 at qq dot com
New email:
PHP Version: OS:

 

 [2018-03-17 07:43 UTC] 860760361 at qq dot com
Description:
------------
---
From manual page: http://www.php.net/mongodb-driver-manager.executequery
---
using the current version of mongodb driver,it has a bug in building a filter for a query when use '$or' operator to the same field.
there is field named "foo" ,not every docs has this field. I want to search a list contain the docs that not has field "foo" or "foo" is equal to "value" . I shoud build a filter such as below:
['$or'=>[
'foo'=>['$exists'=>false],
'foo'=>['$eq'=>"value"]
]]
so the key has named twitce,we can't use array to define a filter 

Expected result:
----------------
may be
['$or'=>[
['foo',['$exists'=>false]],
['foo',['$eq'=>"value"]]
]]
or
{ $or : [ { foo : { $exists: false } }, { foo : value } ] }


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-17 08:18 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-03-17 08:18 UTC] requinix@php.net
> I shoud build a filter such as below:
No, that array structure is incorrect. $or is an array containing conditions and a [foo=>value] array is one condition.

['$or' => [
  ['foo' => ['$exists' => false]],
  ['foo' => ['$eq' => "value"]]
]]
 [2018-03-17 10:12 UTC] 860760361 at qq dot com
it's confirmed,thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC