title: CakePHP query params OFFSET?
body: <p>I'm trying create a SELECT to return some values. I want return these values paginated with LIMIT and OFFSET. To do it I'm trying create a query but doesn't works and throws a syntax exception of mysql.</p>
  
  <p>How could I do it ?</p>
  
  <pre><code>public function findTarefas(){
              $this-&gt;autoRender = false;            
              $json = $this-&gt;request-&gt;input("json_decode", true);
              $id = $json["Pessoa"]["id"];
              $offset = $json["Pessoa"]["offset"];
  
              $tarefas = $this-&gt;Tarefa-&gt;query("SELECT * FROM responsavel_alunos RespAlunos "
                      . "INNER JOIN pessoas Responsavel ON (RespAlunos.pessoas_id = Responsavel.id) "
                      . "INNER JOIN pessoas Aluno ON (RespAlunos.pessoas_id1 = Aluno.id) "
                      . "INNER JOIN matriculas Matricula ON (Matricula.pessoas_id = Aluno.id) "
                      . "INNER JOIN turmas Turma ON (Matricula.turmas_id = Turma.id) "
                      . "INNER JOIN tarefas Tarefa ON (Tarefa.turmas_id = Turma.id) "
                      . "INNER JOIN disciplinas Disciplina ON (Tarefa.disciplinas_id = Disciplina.id) "
                      . "INNER JOIN pessoas Professor ON (Tarefa.pessoas_id = Professor.id) "
                      . "WHERE (Responsavel.id = ?) ORDER BY Tarefa.created DESC LIMIT 5 OFFSET ? ",
                      array($id, $offset)                    
                      );            
  
              $array;       
              if($tarefas){
                  $array = array("status"=&gt;"1", "result"=&gt;$tarefas);
              }else{
                  $array = array("status"=&gt;"0", "result"=&gt;$tarefas);
              }
  
              return json_encode($array);
          }
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>{
      "code": 500,
      "name": "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0'' at line 1",
      "message": "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0'' at line 1",
      "url": "/PainelEscolar/Tarefas/findTarefas.json",
      "error":
      {
          "errorInfo":
          [
              "42000",
              1064,
              "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0'' at line 1"
          ],
          "queryString": "SELECT * FROM responsavel_alunos RespAlunos INNER JOIN pessoas Responsavel ON (RespAlunos.pessoas_id = Responsavel.id) INNER JOIN pessoas Aluno ON (RespAlunos.pessoas_id1 = Aluno.id) INNER JOIN matriculas Matricula ON (Matricula.pessoas_id = Aluno.id) INNER JOIN turmas Turma ON (Matricula.turmas_id = Turma.id) INNER JOIN tarefas Tarefa ON (Tarefa.turmas_id = Turma.id) INNER JOIN disciplinas Disciplina ON (Tarefa.disciplinas_id = Disciplina.id) INNER JOIN pessoas Professor ON (Tarefa.pessoas_id = Professor.id) WHERE (Responsavel.id = ?) ORDER BY Tarefa.created DESC LIMIT 5 OFFSET ?"
      }
  }
  </code></pre>