Skip to content

Commit

Permalink
docs: document single value as .query second argument
Browse files Browse the repository at this point in the history
closes #1979
  • Loading branch information
anliting authored and dougwilson committed Jun 13, 2018
1 parent 6454f19 commit 48cff07
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Readme.md
Expand Up @@ -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
Expand Down

0 comments on commit 48cff07

Please sign in to comment.