jeudi 16 avril 2015

Use NSArray in SQLite Statement

I use SQLite.swift and want to replace the question marks in a statement. This can be done for single entries like this:



let stmt = db.prepare("INSERT INTO users (email) VALUES (?)")
for email in ["betty@icloud.com", "cathy@icloud.com"] {
stmt.run(email)
}


I did not see how I can do the following to use a array like:



var values:[String] = ["test1","test2", "test3"]


in a Statement like:



let stmt = db.prepare("SELECT * from users where email in (?)")


The following does not work:



stmt.run(values)


How do I use an NSArray as an argument for a statement?


Aucun commentaire:

Enregistrer un commentaire