I just wrote a simple function, that creates me a INSERT string out of the input the user has made, so I get something like this(working with ionic btw):
INSERT INTO people(firstname, lastname) VALUES (??)
Now I would like to use a Array that holds the inputvalues as parameter:
let inputvalues = ["value1", "value2"]; this.database.executeSql(this.createInserString("people",this.userData), [inputvalues]).then((data) => { console.log("INSERTED: " + JSON.stringify(data)); }, (error) => { console.log("ERROR-Insert: " + JSON.stringify(error.err)); });
Is there a way to implement something like this? (because otherwise I have to type out ever single input values and ... there are a lot ;-( )
Thank you!
1 Answers
Answers 1
i think you should separate parameters with comma:
INSERT INTO people(firstname, lastname) VALUES (?,?)
and then use the array without "[ ]" since its already an array:
this.database.executeSql(this.createInserString("people",this.userData), inputvalues)
0 comments:
Post a Comment