Blogger Information
Blog 30
fans 0
comment 0
visits 18188
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
4月24日 预处理实现更新删除操作
宋的博客
Original
530 people have browsed it

更新操作

实例

<?php

//链接数据库

require 'mysqli_connect.php';

//准备sql语句
$sql = "UPDATE staff set age=? where name=?;";


//创建stmt对象,
$stmt =$mysqli->stmt_init();


//stmt检测对象的预处理语句是否正确s

mysqli_stmt_prepare($stmt,$sql);

//将变量与语句绑定
	mysqli_stmt_bind_param($stmt,'is',$age,$name);
	$age=30;$name='小龙女';

//执行SQL
mysqli_stmt_execute($stmt);

//注销stmt	
mysqli_stmt_close($stmt);
//关闭数据里链接
$mysqli->close();

  ?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

删除操作

实例

<?php

//链接数据库

require 'mysqli_connect.php';

//准备sql语句
$sql = "DELETE from  staff  where name=?;";



//创建stmt对象,
$stmt =$mysqli->stmt_init();


//stmt检测对象的预处理语句是否正确

mysqli_stmt_prepare($stmt,$sql);

//将变量与语句绑定
	mysqli_stmt_bind_param($stmt,'s',$name);
	$name='小龙女';

//执行SQL
mysqli_stmt_execute($stmt);

//注销stmt	
mysqli_stmt_close($stmt);
//关闭数据里链接
$mysqli->close();

  ?>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!