Try this for debugging SQL queries
throws a Notice: Attempting to quote a value without specific driver level support can introduce security vulnerabilities in a production environment.
To get also (not only remove the notice) a correct SQL query:
For Platform MySQL it makes not correct query. An integer from SQL query LIMIT part
what throws an error in MySQL.