Ionic-cordova-SQLite can Array be inserted as parameter?

I just wrote a simple function that creates an INSERT string for me from the user input, so I get something like this (working with ionic btw):

    INSERT INTO people(firstname, lastname) VALUES (??)

      

Now I would like to use an array that contains the input values ​​as a 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 all single inputs and ... there are many ;-()

Thank!

+3


source to share


1 answer


I think you should separate the parameters with a comma:

INSERT INTO people(firstname, lastname) VALUES (?,?)

      



and then use an array without "[]" since its already an array:

this.database.executeSql(this.createInserString("people",this.userData), inputvalues)

      

+4


source







All Articles