Skip to content

Commit 6b0fba8

Browse files
committed
Clarifying docs note on prepared statement advantages
1 parent afda8c7 commit 6b0fba8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ 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 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 when compared to static statements, and prevent SQL injection attacks.
68+
69+
Additionally, if you wish to execute the same statement multiple times, you can reuse prepared statements and avoid recompiling the same statement multiple times.
6870
:::
6971

7072
Example of a prepared statement with dynamically bound value:

0 commit comments

Comments
 (0)