I am using Cakephp 2.X version
Im going to run sql like:
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
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.
To execute this complex sql, How can I override paginate() to paginate my result?
Description:
I try to do Custom Query Pagination. The Controller get keywords and generate the SQL, I want to pass SQL string to public function paginate(Model $model, $conditions, $fields, $order, $limi ...)
function which is overridded in Model to run this custom query. How could i pass SQL string to paginate function.
Any suggestion or hint please?