title: CakePHP TIMESTAMPDIFF in SELECT statement
body: <p>In my controller in CakePHP I am attempting to get the difference between two dates.  Here is the regular query that I know works in traditional SQL.</p>
  
  <pre><code>SELECT TIMESTAMPDIFF(SECOND, posts.post_date, answers.answer_date) AS 'timestampdiff' 
  FROM answers 
  INNER JOIN questions ON answers.question_id = questions.id
  INNER JOIN tags_questions ON questions.id = tags_questions.question_id 
  INNER JOIN tags ON tags.id = tags_questions.tag_id 
  INNER JOIN posts ON posts.id = questions.posts_id WHERE tags.id = 1;
  </code></pre>
  
  <p>Now in CakePHP3.0 (that is the version I am using). I am attempting to build the same exact query (shown above) but using the query builder CakePHP has. I ended up constructing that query below:</p>
  
  <pre><code>$time_diffs = $this-&gt;Answers-&gt;find('all')
  -&gt;join(['Questions' =&gt; [
       'table' =&gt; 'questions',
       'type' =&gt; 'INNER',
       'conditions' =&gt; array('Answers.question_id = Questions.id')
  ]])
  -&gt;join(['TagsQuestions' =&gt; [
       'table' =&gt; 'tags_questions',
       'type' =&gt; 'INNER',
       'conditions' =&gt; array('TagsQuestions.question_id = Questions.id')
  ]])
  -&gt;join(['Tags' =&gt; [
       'table' =&gt; 'tags',
       'type' =&gt; 'INNER',
       'conditions' =&gt; array('TagsQuestions.tag_id = Tags.id')
  ]])
  -&gt;join(['Posts' =&gt; [
       'table' =&gt; 'posts',
       'type' =&gt; 'INNER',
       'conditions' =&gt; array('Questions.post_id = Posts.id')
  ]])
  -&gt;select(['timestampdiff' =&gt; 'TIMESTAMPDIFF(SECOND, Posts.post_date, Answers.answer_date)'])
  -&gt;where(['Tags.id' =&gt; 1])-&gt;toArray();
  </code></pre>
  
  <p>Now here is where the error comes into play. When I execute the CakePHP controller code, I get the this: </p>
  
  <p>"Error: SQLSTATE[42000]: Syntax error or access violation: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SECOND, Posts.post_date, Answers.answer_date') AS 'timestampdiff' FROM 'answers' at line 1."</p>
  
  <p>When I went to go check what sort of query CakePHP generated for me, I found a similar but slightly different query from the original one I wrote (first block of code). </p>
  
  <pre><code>SELECT TIMESTAMPDIFF(`SECOND, posts.post_date, answers.answer_date`) AS 'timestampdiff' 
  FROM answers 
  INNER JOIN questions ON answers.question_id = questions.id
  INNER JOIN tags_questions ON questions.id = tags_questions.question_id 
  INNER JOIN tags ON tags.id = tags_questions.tag_id 
  INNER JOIN posts ON posts.id = questions.posts_id WHERE tags.id = 1;
  </code></pre>
  
  <p>Now here is the part I do not understand, why did CakePHP generate those odd ` quotes symbols around my parameters for the TIMESTAMPDIFF in CakePHP? I know that if I remove them, the query will work just fine. I suppose my question is, given the error I'm getting? How can I modify the querybuild CakePHP code to not have those odd ` symbols near my parameters? </p>