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!
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With