Search code examples
sqlescapingappcelerator-mobile

appcelerator escape query string


I'm looking for a way to escape all characters in javascript so i can insert them into a database. But i don't want to use escape() because that's breaking my code.

now getting this error:

[ERROR] invalid SQL statement. Error Domain=com.plausiblelabs.pldatabase Code=3 "An error occured parsing the provided SQL statement." UserInfo=0x6de2b50 {com.plausiblelabs.pldatabase.error.vendor.code=1, NSLocalizedDescription=An error occured parsing the provided SQL statement.

com.plausiblelabs.pldatabase.error.query.string=INSERT INTO vac ( category, title, url, description) VALUES ( '201', ' Adviseur Bankshop', 'someurl', 'description \'t more text.')


Solution

  • You can use parameters in Appcelerator.

    DB.db.execute(
        "INSERT INTO feeds (title, description) VALUES (?, ?)",
        'Good News!', 'A little description'
    );