Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs mysql query

//The second form .query(sqlString, values, callback) comes when using placeholder values 
connection.query('SELECT * FROM `books` WHERE `author` = ?', ['David'], function (error, results, fields) {
  // error will be an Error if one occurred during the query
  // results will contain the results of the query
  // fields will contain information about the returned results fields (if any)
});

//The third form .query(options, callback) comes when using various advanced options on the query
connection.query({
  sql: 'SELECT * FROM `books` WHERE `author` = ?',
  timeout: 40000, // 40s
  values: ['David']
}, function (error, results, fields) {
  // error will be an Error if one occurred during the query
  // results will contain the results of the query
  // fields will contain information about the returned results fields (if any)
});
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #nodejs #mysql #query
ADD COMMENT
Topic
Name
1+5 =