Search code examples
swiftfmdb

Swift FMDB modifiers


where are the modifiers for SQL FMDB described ? In particular, how do I place a quote within a string I wish to insert. Such as I wish to insert name "Mac's Place" into the database ? thanks


Solution

  • If you use executeUpdate with ? placeholders in the SQL and then supply the parameters as arguments in the array, you don't have to quote the special characters in the string. For example, you can:

    if !db.executeUpdate("insert into restaurants (name) values (?)", withArgumentsInArray: ["Mac's Place"]) {
        println(db.lastErrorMessage())
    }