MySQL的预处理技术使用测试
MySQL预处理技术:
1.减轻服务器压力
2.防止sql注入,把传递过去的危险字符也只当做参数处理
3.将sql语句强制一分为二:第一部分为前面相同的命令和结构部分,第二部分为后面可变的数据部分
基本使用
prepare sql_1 from "select * from mass_list";
execute sql_1;
drop prepare sql_1;
传参:
prepare sql_2 from "select * from mass_list where id=?";
set @id=1;
execute sql_2 using @id;
set @id=1;
execute sql_2 using @id;
prepare sql_3 from "insert into mass_list (mass_name) values(?)";
set @name='zhang';
execute sql_3 using @name;
prepare sql_3 from "insert into mass_list (mass_name,user_email_id) values(?,?),(?,?)";
set @name='zhang';
set @id=1;
execute sql_3 using @name,@id,@name,@id;//参数按顺序传递
set @name='zhang';
set @id=1;
execute sql_3 using @name,@id,@name,@id;//参数按顺序传递
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11