symfony - Doctrine one to many relationship issue -


I have two entities

Resorts and inventory entries

of the resort list In the room there are many relationships with one.

I need to apply a condition to the table on the table.

I have already created a query using DQL but it returns all the results from the list. It is not enforcing the conditions. Choose

  $ qb-> ('ih.id, rr') - & gt; From ('\ base \ Entity \ Avp \ ResortRooms' 'RR') - & gt; Leftjoin ('rr.inventory', 'ih'); If ($ data ['nummales']): $ qb- & gt; And where ('ih.malesCount & gt; =: men') - & gt; Setpimeter ("male", ($ int $) [data 'nummales']);  

I want a result from the list whose male number is 2.

I have two organizations below

Resort Room

  Class Resort Extended Rums Is \ base \ unit \ base \ baseInti {/ ** * @ integer * * @ORM \ column (name = "id", type = "integer", drain = false) * @ORM \ id * @ORM = Generated value (Strategy = "identity") * / protected $ id; / ** * @string string * * @ORM \ column (name = "title", type = "string", length = 255, falsifiable = false) * $ / protected title; / ** * @ string string * * @ORM \ column (name = "description", type = "text", faucet = true) * / protected $ description; / ** * @ integer * * @ORM \ column (name = "resort_id", type = "integer", faucet = incorrect) * / protected $ resortId; / ** * Water String * * @ORM \ column (name = "value", type = "decimal", precision = 10, scale = 0, faucet = wrong) * / protected $ value = '0'; / ** * Wave string * * @ORM \ column (name = "image", type = "string", length = 50, faucet = true) * $ / protected image; / ** * @ string string * * @ORM \ column (name = "meta_title", type = "string", length = 255, faucet = true) * / protected $ metatit; / ** * @ wise \ datetime * * @ORM \ column (name = "last_upjected", type = "day-time", faucet = true) * / protected $ last update; / ** * @ integer * * @ORM \ column (name = "in_stock", type = "integer", falsify = false) * / protected $ inStock = '0'; / ** * @ integer * * @ORM \ OneToMany (target = "base \ object \ inventariatlus", mapped = "room id") * $ / protected $ inventory; Public function __ composition () {$ this- & gt; Inventory = new ArrayCollection (); } Public Function getInventory () {Return $ this- & gt; List; }  

Inventory Hotel

  Expands class inventory hotel base \ basement {/ ** * @ integer * * @ORM \ column (name = "id", type = "integer", drain = false) * @ORM \ Id * @ORM \ generated value (strategy = "detection") * / protected $ id; / ** * @ integer * * @ORM \ column (name = "resort_id", type = "integer", faucet = incorrect) * / protected $ resortId; / ** * @ Vara \ Base \ Unit \ A VP \ Resort Rooms * * @ORM \\ \ "\" Lots (Target Entity = "Base \ Unit \ AVP \ Resort Rooms", Invoked By = "Inventory ") * @ORM \ JoinColumns ({* @ORM) Insert column (name =" room_ID ", referenced column name =" id "))}} * $ / protected $ id;  

Can you post the entire query? I do not see where before nor in the second unit.

And where () is used when there is a place in the first place but if possible, I suggest to keep it cleaner and go to the same place for many parameters where: / P>

  -> Where (array ('param1' = & gt; 1, 'param2' = & gt; If the relationship is bidirectional, then you can go to the repository:  
  $ em-> getRepository ('2)) - & gt; setParameters ()  

repo: entity') - & gt; FindByMalesCount ($ data ['numMales']);


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -