title: CakePHP pass custom query from controller into model paginate()
body: <p>I am using Cakephp 2.X version</p>
  
  <p>Im going to run sql like: </p>
  
  <pre><code> SELECT field1, field2, field3, field3,
              ( IF(LOCATE('abc', field1), 4, 0) + IF(LOCATE('abc', field2), 3, 0) + IF(LOCATE('abc', field3), 2, 0) ) AS score
              FROM sometable
              WHERE ( (field1 LIKE '%abc%')  OR  (field2 LIKE '%abc%')  OR  (field3 LIKE '%abc%') )
              ORDER BY score DESC
  </code></pre>
  
  <p>this sql is generated by code dynamically. So this sql need to be passed into paginate() function in order to do the pagination by cakephp. It seems that cakephp pagination function is not flexible enough to deal with complex sql.</p>
  
  <p>To execute this complex sql, How can I override paginate() to paginate my result?</p>
  
  <p>Description:</p>
  
  <p>I try to do Custom Query Pagination. The Controller get keywords and generate the SQL, I want to pass SQL string to <code>public function paginate(Model $model, $conditions, $fields, $order, $limi ...)</code> function which is overridded in Model to run this custom query. How could i pass SQL string to paginate function.</p>
  
  <p>Any suggestion or hint please?</p>