title: Preventing Doctrine's query cache in Symfony
body: <p>In my Symfony/Doctrine app, I have a query that orders by RANDOM().  I call this same method several times, but it looks like the query's result is being cached.</p>
  
  <p>Here's my relevant code:</p>
  
  <pre><code>$query = $table-&gt;createQuery('p')
      -&gt;select('p.*, RANDOM() as rnd')
      -&gt;orderBy('rnd')
      -&gt;limit(1)
      -&gt;useQueryCache(null)
      -&gt;useResultCache(null);
  $result = $query-&gt;fetchOne();
  </code></pre>
  
  <p>Unfortunately, the same record is returned every time, regardless of me passing <code>null</code> to both <code>useQueryCache</code> and <code>useResultCache</code>.  I tried using <code>false</code> instead of <code>null</code>, but that didn't work either.  Lastly, I also tried calling both <code>setResultCacheLifeSpan(0)</code> and <code>setResultCacheLifeSpan(-1)</code>, but neither call made a difference.</p>
  
  <p>Any insight on how to prevent caching since I want a different random row to be selected each time I call this method?</p>
  
  <p><strong>Edit:</strong> I also tried calling <code>clearResultCache()</code>, but that just ended up causing an error stating: "Result Cache driver not initialized".</p>
  
  <p><strong>Edit 2:</strong> As requested, here's the SQL generated by calling <code>$query-&gt;getSqlQuery()</code>:</p>
  
  <pre><code>SELECT c.id AS c__id, c.name AS c__name, c.image_url AS c__image_url,
  c.level AS c__level, c.created_at AS c__created_at, c.updated_at
  AS c__updated_at, RANDOM() AS c__0 FROM cards c ORDER BY c__0 LIMIT 1
  </code></pre>