title: Extbase TYPO3 - Expand query with custom WHERE parts
body: <p>I have a model ("offers") that has the attributes lat/lng among many other meta attributes. Inside a repository method I am able to fetch offers according to matching metadata like:</p>
  
  <pre><code>$where[] = $query-&gt;equals('special', 1);
  $where[] = $query-&gt;equals('region', 7);
  $where[] = $query-&gt;greaterThan('crdate', $minTime);
  </code></pre>
  
  <p>Now I need to be able to to a radius search depending on the lat/lng attributes. In a usual SQL query this would be something like:</p>
  
  <pre><code>WHERE acos(sin(:lat)*sin(radians(lat)) + cos(:lat)*cos(radians(lat))*cos(radians(lng)-:lng)) * :R &lt; :rad
  </code></pre>
  
  <p>However since this contains mathematic values, I don't see a possibility to add a $query counterpart. How cann I pass a WHERE portion like this to an extbase query?</p>
  
  <p>What I would like to avoid:</p>
  
  <ul>
  <li><p>Using a raw admin_query() with $GLOBALS['TYPO3_DB'] with all the same $where conditions that I gathered before the execute() method of the proper Query, to gather the UIDs of the available records, and append the $query with a condition that only returns those matching the UID of the second query</p></li>
  <li><p>Rewriting the whole repository method to use a raw sql method and iterate that to generate the propery ER-Model of Extbase.</p></li>
  </ul>
  
  <p>So ideally, I'd like to have something like:</p>
  
  <pre><code>$query-&gt;customSQL('blablabla &gt; bla');
  </code></pre>
  
  <p>which would get appended to the SQL WHERE part later on. Maybe I could first create a placeholder like</p>
  
  <pre><code>$query-&gt;equals('placeholder', 1);
  </code></pre>
  
  <p>and then somehow get the statement before execution, do a</p>
  
  <p>str_replace('placeholder = 1', '...my real radius statement...')</p>
  
  <p>But I only see a getStatement() not a setStatement() in the QueryInterface...</p>