node.js - Insert Multiple records in nodejs in single Query -
i inserting dynamic records
var sql = "insert test (name, email, n) values ?"; var values = [ ['test', 'demian@gmail.com', 1], ['test', 'john@gmail.com', 2], ['mark', 'mark@gmail.com', 3], ['pete', 'pete@gmail.com', 4] ]; conn.query(sql, [values], function(err) { if (err) throw err; conn.end(); });
here example working fine
now data here
var arr = category_ids.split(","); (var = 0; < arr.length; i++) { }
how make dynamic array of values in loop
thanks
you need array of arrays, values
in example provided.
your example
var arr = category_ids.split(","); var values = [ arr ];
or
var value = [ category_ids.split(",") ];
Comments
Post a Comment