Parameters on LIMIT and OFFSET not working

436 views Asked by At

Im trying to implement pagination by parameterized my limit from request URL unfortunately I'm having error.

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 ''25'' at line 1

Here is the code for sql syntax. Need your help badly. queryExecute("SELECT * FROM TABLE_NAME LIMIT :limit",{limit:rc.limit});

1

There are 1 answers

1
CfSimplicity On BEST ANSWER

The limit parameter is being passed as a string by default, whereas the database requires an integer value. Try specifying the type:

queryExecute("SELECT * FROM TABLE_NAME LIMIT :limit",{limit:{value:rc.limit,sqltype:"integer"}});