I need to find a way to filter results from a MongoDB database, based on fields found in the current table, and a field found in another table which is linked to the current table. Tables format:
{
"_id": ObjectId("51af256a0da4dd7804000007"),
"enddate": ISODate("2013-06-14T21:00:00.0Z"),
"main": false,
"name": "name 1",
"photo": "image-1.jpg",
"site": {
"$ref": "Sites",
"$id": ObjectId("51ac538c5f06751414bd9f98"),
"$db": "local"
},
"startdate": ISODate("2013-04-30T21:00:00.0Z")
}
{
"_id": ObjectId("51d3d5b9caa8213b12e92c5e"),
"sitefeatured": false,
"sitename": "a",
"sitephoto": "aa.jpg",
"siteurl": "aaaa.com/"
}
what i`m trying to do in ->where clause is to search in the string formed by this.name and this.site.sitename: my problem is that i don't know / didn't find how to reference to property sitename of the site object
$entries = $dm
->getRepository($sTable)
->createQueryBuilder('o')
->where('function() { return ( (this.name + this.site.sitename).toLowerCase().indexOf("'.$_GET['sSearch'].'".toLowerCase()) !== -1 ) ? true : false }')
->sort($aColumns[$_GET['iSortCol_0']], $_GET['sSortDir_0'])
->limit($_GET['iDisplayLength'])
->skip($_GET['iDisplayStart'])
->getQuery()
->execute();
Is there anything like SQL join that i didn't came across, or what's the solution?