Bug #76108 [Nab]: error in build filter with array

From: Date: Sat, 17 Mar 2018 10:12:52 +0000
Subject: Bug #76108 [Nab]: error in build filter with array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214392@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76108&edit=1

 ID:                 76108
 User updated by:    860760361 at qq dot com
 Reported by:        860760361 at qq dot com
 Summary:            error in build filter with array
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 PHP Version:        7.0.28
 Block user comment: N
 Private report:     N

 New Comment:

it's confirmed,thanks


Previous Comments:
------------------------------------------------------------------------
[2018-03-17 08:18:08] 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 07:43:33] 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 } ] }



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=76108&edit=1


Thread (3 messages)

« previous php.bugs (#214392) next »