预处理

最近更新时间:2021-03-01 15:56:24

SQL 类型的支持:

  • PREPARE Syntax
  • EXECUTE Syntax

二进制协议的支持:

  • COM_STMT_PREPARE
  • COM_STMT_EXECUTE

示例:

mysql> select * from test1;
+---+------+
| a | b    |
+---+------+
| 5 |    6 |
| 3 |    4 |
| 1 |    2 |
+---+------+
3 rows in set (0.03 sec)
mysql> prepare ff from "select * from test1 where a=?";
Query OK, 0 rows affected (0.00 sec)
Statement prepared
    mysql> set @aa=3;
Query OK, 0 rows affected (0.00 sec)
    mysql> execute ff using @aa;
+---+------+
| a | b    |
+---+------+
| 3 |    4 |
+---+------+
1 row in set (0.06 sec)