In mongodb bash I can do this:
db.collection.find({'field1': /^value1/, 'field2': /^value2/, 'field2': /^value3/});
It is very convenient when field2
is an array. The alternative is:
db.collection.find({'$and': [
{'field1': /^value1/},
{'field2': /^value2/},
{'field2': /^value3/}
]});
... which is inconvenient.
But I can't use the first query in php because php array keys must be unique. Is there any way to do this query in php?