I am using 'mysql' library in Node
This is what i use instead of prepared statement, and works just fine :
connection.query("update table set col1=? where col2=1",[val1],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});
However, this doesn't work for 2 unkowns :
connection.query("update table set col1=? where col2=?",[val1],[val2],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});
The error message says "undefined is not a function". What am i doing wrong?
You need to define the values in a single array, like this:
connection.query("update table set col1=? where col2=?",[val1,val2],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});
All the necessary functionality can be easily found here: https://github.com/felixge/node-mysql/#preparing-queries
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