预处理插入语句
$m=new mysqli('localhost','root','','db');
$m->set_charset('utf8');
$stmt=$m->prepare('insert into stu values(null,?,?,?)');
$n='aa';
$g='保密';
$s=10;
$stmt->bind_param('ssi',$n,$g,$s);
$stmt->execute();
$stmt->close();
$m->close();
预处理实现数据删除
$m=new mysqli('localhost','root','','db');
$m->set_charset('utf8');
$stmt=$m->prepare('delete from stu where sid in (?,?)');
$id1=1;
$id2=2;
$stmt->bind_param('ii',$id1,$id2);
$stmt->execute();
$stmt->free_result();
$stmt->close();
$m->close()
使用预处理语句实现数据的修改
$m=new mysqli('localhost','root','','db');
$m->set_charset('utf8');
$stmt=$m->prepare('update stu set sname=? where sid=?');
$s='hello';
$d=7;
$stmt->bind_param('ss',$s,$d);
$stmt->execute();
$stmt->free_result();
$stmt->close();
$m->close();