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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Sat Dec 21 14:01:32 2024 UTC