问题
I'm using MongoDB with PHP's own driver and I have saved multiple arrays under main document. Structure looks like this:
[
{
_id: 5,
unique: true,
name: "Joseph",
password: "mangalore"
},
{
_id: 9,
unique: true,
name: "John",
password: {
passcode1: 1,
passcode2: 2
}
}
]
Note: I want to fetch the data where passcode2 > 1
Note: Can u please show me both php and laravel code
My code is
$id = DB::connection('mongodb')
->collection('login2')
->where(array('password.passcode2','>',2))
->get();
return $id;
来源:https://stackoverflow.com/questions/42383151/how-to-query-for-nested-array-in-php-and-laravel-using-mongodb