I am trying to do the equivalent of MongoDB, which should return all users called Joe Bloggs, that have at least one address where the City is defined as London:
db.users.findOne() {
name : "Joe Bloggs",
addresses : [{city: "London"}]
}
Using the Kohana 3 PHP module Mango: https://github.com/Wouterrr/MangoDB
I can return results based on top level objects like so:
foreach(Mango::factory('users', array(
'name' => 'Joe Bloggs',
))->load(FALSE) as $user) {
}
But I can't work out how to return results based on objects in arrays, I have tried variations of:
foreach(Mango::factory('users', array(
'name' => 'Joe Bloggs',
'addresses' => array('city' => 'London'),
))->load(FALSE) as $user) {
}
and:
foreach(Mango::factory('users', array(
'name' => 'Joe Bloggs',
'addresses.$.city' => 'London',
))->load(FALSE) as $user) {
}
I think I'm really close I'm just stuck at the last.