Skip to content

Commit f057455

Browse files
Oxyjunlambrospetrou
authored andcommitted
[D1] Clarifying docs note on the advantages of prepared statements (#24207)
* Clarifying docs note on prepared statement advantages * Wording update * nit * Update src/content/docs/d1/worker-api/prepared-statements.mdx Co-authored-by: Lambros Petrou <[email protected]> * Adding cross-links --------- Co-authored-by: Lambros Petrou <[email protected]>
1 parent 221e5b1 commit f057455

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/content/docs/d1/worker-api/prepared-statements.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ const stmt = env.DB.prepare("SELECT * FROM Customers WHERE CompanyName = ?").bin
6363

6464
D1 API supports static statements. Static statements are SQL statements where the variables have been hard coded. When writing a static statement, you manually type the variable within the statement string.
6565

66-
:::note
67-
The recommended approach is to bind parameters to create a prepared statement (which are precompiled objects used by the database) to run the SQL. Prepared statements lead to faster overall execution and prevent SQL injection attacks.
66+
:::note[Advantages of prepared statements]
67+
The recommended approach is to use [prepared statements](/d1/worker-api/d1-database/#prepare) to run the SQL and bind parameters to them. Binding parameters using [`bind()`](/d1/worker-api/prepared-statements/#bind) to prepared statements allows you to reuse the prepared statements in your code, and prevents SQL injection attacks.
68+
6869
:::
6970

7071
Example of a prepared statement with dynamically bound value:

0 commit comments

Comments
 (0)