Skip to content

Commit 10e35f8

Browse files
committed
docs: include tags
1 parent 10f6988 commit 10e35f8

File tree

6 files changed

+39
-49
lines changed

6 files changed

+39
-49
lines changed

website/docs/documentation/prepared-statements.mdx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
tags: [Prepared Statements, execute]
3+
---
4+
15
# Prepared Statements
26

37
## Automatic creation, cached and re-used by connection
@@ -39,11 +43,11 @@ connection.prepare('select ? + ? as tests', (err, statement) => {
3943

4044
Note that you should not use statement after connection reset (`changeUser()` or disconnect). Statement scope is connection, you need to prepare statement for each new connection in order to use it.
4145

42-
# Configuration
46+
## Configuration
4347

4448
`maxPreparedStatements` : We keep the cached statements in a [lru-cache](https://github.com/isaacs/node-lru-cache). Default size is `16000` but you can use this option to override it. Any statements that are dropped from cache will be `closed`.
4549

46-
# Serialization of bind parameters
50+
## Serialization of bind parameters
4751

4852
The bind parameter values passed to `execute` are serialized JS -> MySQL as:
4953

@@ -57,3 +61,32 @@ The bind parameter values passed to `execute` are serialized JS -> MySQL as:
5761
- Other -> `VAR_STRING`
5862

5963
Passing in `undefined` or a `function` will result in an error.
64+
65+
## Prepared Statements Helper
66+
67+
MySQL2 provides `execute` helper which will prepare and query the statement. You can also manually prepare / unprepare statement with `prepare` / `unprepare` methods.
68+
69+
```js
70+
connection.execute(
71+
'select ?+1 as qqq, ? as rrr, ? as yyy',
72+
[1, null, 3],
73+
(err, rows, fields) => {
74+
console.log(err, rows, fields);
75+
connection.execute(
76+
'select ?+1 as qqq, ? as rrr, ? as yyy',
77+
[3, null, 3],
78+
(err, rows, fields) => {
79+
console.log(err, rows, fields);
80+
connection.unprepare('select ?+1 as qqq, ? as rrr, ? as yyy');
81+
connection.execute(
82+
'select ?+1 as qqq, ? as rrr, ? as yyy',
83+
[3, null, 3],
84+
(err, rows, fields) => {
85+
console.log(err, rows, fields);
86+
}
87+
);
88+
}
89+
);
90+
}
91+
);
92+
```

website/docs/examples/execute.mdx

Lines changed: 0 additions & 47 deletions
This file was deleted.

website/docs/examples/prepared-statements/delete.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 3
3+
tags: [Prepared Statements, Placeholders, Parameters, execute]
34
---
45

56
import Tabs from '@theme/Tabs';

website/docs/examples/prepared-statements/insert.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 0
3+
tags: [Prepared Statements, Placeholders, Parameters, execute]
34
---
45

56
import Tabs from '@theme/Tabs';

website/docs/examples/prepared-statements/select.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 1
3+
tags: [Prepared Statements, Placeholders, Parameters, execute]
34
---
45

56
import Tabs from '@theme/Tabs';

website/docs/examples/prepared-statements/update.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
sidebar_position: 2
3+
tags: [Prepared Statements, Placeholders, Parameters, execute]
34
---
45

56
import Tabs from '@theme/Tabs';

0 commit comments

Comments
 (0)