标签:
预处理插入语句
$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();
标签:
原文地址:http://www.cnblogs.com/lsr111/p/4544814.html