From 48cff07afa7d8741cc560b5d4a093464a6d8fdee Mon Sep 17 00:00:00 2001 From: anliting Date: Mon, 2 Apr 2018 15:22:25 +0800 Subject: [PATCH] docs: document single value as .query second argument closes #1979 --- Readme.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Readme.md b/Readme.md index 97b1b2dd8..ce66a5764 100644 --- a/Readme.md +++ b/Readme.md @@ -661,6 +661,22 @@ connection.query({ ); ``` +If the query only has a single replacement character (`?`), and the value is +not `null`, `undefiend`, or an array, it can be passed directly as the second +argument to `.query`: + +```js +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) + } +); +``` + ## Escaping query values **Caution** These methods of escaping values only works when the