Help with Javascript SQL INSERT

levi picture levi · Jul 26, 2011 · Viewed 7.3k times · Source

I have the following code which inserts a "task" into a table with a value for the "task". I am trying to modify this statement to insert multiple values into multiple columns, but I cant seem to get it to work since I am unfamiliar with the format.

Can sombody show me how the can be modified to insert multiple values?

var item  = this.$.newItem.getValue();
this.$.db.query( 'INSERT INTO tasks ( task ) VALUES ( ? )', { values: [ item ] } ); 

Thanks alot.

Answer

diagonalbatman picture diagonalbatman · Jul 26, 2011

I am assuming you didn't mean to tag this MySQL....

However - a useful class for helping out with Enyo DB queries is:

https://github.com/onecrayon/database-webos

One crayon's implementation. Works very nicely for Enyo.