Sunday, 15 January 2012

php - Doctrine ODM - get entities by embedMany collection entities -



php - Doctrine ODM - get entities by embedMany collection entities -

i have collection embedmany field "properties"

{ "title": "castle in scotland", "properties": { "0": { "_id": numberint(13), "proptype": { "$ref": "listing_property_types", "$id": numberint(9), "$db": "real_estate" }, "propoption": { "$ref": "listing_property_options", "$id": numberint(13), "$db": "real_estate" } }, "1": { "_id": numberint(15), "proptype": { "$ref": "listing_property_types", "$id": numberint(10), "$db": "real_estate" }, "propoption": { "$ref": "listing_property_options", "$id": numberint(15), "$db": "real_estate" } } }

how build query if want entity has propery proptype.$id=9 , propoption=13

i seek this

$builder = $this->createquerybuilder()->select(); foreach ($propertiesarr $proptypeid => $propoptid) { if (intval($proptypeid) > 0 && intval($propoptid) > 0) { $builder->addor( $builder->expr() ->field('properties.proptype.$id')->equals($proptypeid) ->field('properties.propoption.$id')->equals($propoptid) ); } } }

but doesn't work

this code snippet doesn't work because $propoptid variable not integer. if wrap $proptypeid , $propoptid in intval code work fine.

php mongodb symfony2 doctrine2 odm

No comments:

Post a Comment