title: How to query database data with Doctrine and Symfony
body: <p>I have a line like this</p>
  
  <pre><code> // $repository is my repository for location data
   $locationObject = $repository-&gt;findOneBy(array('name' =&gt; $locationName));
  </code></pre>
  
  <p>Which selects the first record it can find from the <code>Locations</code> table. Which is fair enough.</p>
  
  <p>However, I have some additional data in that table to make the query more precise. Specifically, an "item_name" column. In the Location class it is specified as such:</p>
  
  <pre><code>/**
   * @ORM\ManyToOne(targetEntity="Item", inversedBy="locations", cascade={"persist", "remove"})
   * @ORM\JoinColumn(name="item_id", referencedColumnName="item_id", onDelete="CASCADE")
   */
  protected $item;
  </code></pre>
  
  <p>So there is also an Item table with item_id, item_name, etc.</p>
  
  <p>What I want to do is change the original <code>findOneBy()</code> to also filter by item name. So I want something like:</p>
  
  <pre><code> $locationObject = $repository-&gt;findOneBy(array('name' =&gt; $locationName, 'item' =&gt; $itemName));
  </code></pre>
  
  <p>But because <code>$item</code> is an object in the Locations class rather than a string or an ID obviously that wouldn't work. So really I want to somehow much against item->getName()...</p>
  
  <p>I'm not sure how I can do this. Does anyone have any suggestions?</p>
  
  <p>Thanks</p>