title: Pass values to an other entity Symfony
body: <p>What I need to do is to export as as .csv a list of a lot of different values inside different entities. I need each reference created at a certain date with related values.</p>
  <p>What I did was first, find all the objects by date and put them in an array.</p>
  <pre><code>$parcelRepo = $this-&gt;getDoctrine()-&gt;getRepository(Parcel::class);
  
      $dateToday = new \DateTime(&quot;now&quot;);
  
      $parcels = $parcelRepo-&gt;findBy([
          'date_add' =&gt; $dateToday
      ]);
  </code></pre>
  <p>Then, in a foreach loop, I find the values that relates to each parcel entity. This is where I have a problem, I don't understand how to access the values which are not located in the same table as my first parcel entity.
  I need to not use SQL as well.</p>
  <p>Here is the code where I get the &quot;Only variables should be passed by reference&quot; error.</p>
  <pre><code>$array = [];
  
  
      foreach ($parcels as &amp;$p) {
          $array.array_push(
              $p-&gt;getDeliveryOrder()-&gt;getProduct()-&gt;getAccount()-&gt;getCoclico(),
              &quot;1&quot;,
              &quot;&quot;,
              $p-&gt;getDeliveryOrder()-&gt;getUser()-&gt;getLogin(),
              $p-&gt;getDeliveryOrder()-&gt;getProduct()-&gt;getCode(),
              $p-&gt;getInternalReference(),
              $p-&gt;getDeliveryOrder()-&gt;getProduct()-&gt;getCode()+&quot;0&quot;+$p-&gt;getNumber(),
              &quot;121&quot;,
              $p-&gt;getName(),
              $p-&gt;getAddress4(),
              $p-&gt;getAddress1(),
              $p-&gt;getAddress2(),
              $p-&gt;getAddress3(),
              &quot;téléphone&quot;, //TODO
              $p-&gt;getPostalCode(),
              $p-&gt;getCity(),
              \DateTime::createFromFormat('Ymd',$dateToday),
              &quot;&quot;,
              &quot;&quot;,
              &quot;0&quot;
          );
      }
  </code></pre>
  <p>I think I need to use QueryBuilder but was wondering if there was any other way to do what I need since QueryBuilder is close to SQL (from what I understand).</p>
  <p>Also, as I need to export each foreach values in one line, I need a multidimensional array. However I did not look into this issue since I can't even get the values I need.</p>