Blogger Information
Blog 22
fans 1
comment 1
visits 22867
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Mysqli预处理
forever浅笑
Original
806 people have browsed it

mysqli_pre_update.php

实例

<?php

// 连接数据库
$db = mysqli_connect('127.0.0.1', 'root', 'root', 'php') or die('数据库连接失败' . mysqli_connect_error());

// 准备sql语句
$sql = "update staff set salary = ? where staff_id = 3";
// 创建预处理对象
$stmt = mysqli_stmt_init($db);
// 用$stmt对象检测当前的预处理语句是否正确
if (mysqli_stmt_prepare($stmt, $sql)) {
	// 将变量与语句中的占位符进行绑定 s:字符串 i:整数 d:小数
	mysqli_stmt_bind_param($stmt,'i',$salary);
	$salary = 1000;
	mysqli_stmt_execute($stmt);
}
mysqli_stmt_close($stmt);
mysqli_close($db);

运行实例 »

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

mysqli_pre_delete.php

实例

<?php

// 连接数据库
$db = mysqli_connect('127.0.0.1', 'root', 'root', 'php') or die('数据库连接失败' . mysqli_connect_error());

// 准备sql语句
$sql = "delete from  staff  where staff_id = 3";
// 创建预处理对象
$stmt = mysqli_stmt_init($db);
// 用$stmt对象检测当前的预处理语句是否正确
if (mysqli_stmt_prepare($stmt, $sql)) {
	// 将变量与语句中的占位符进行绑定 s:字符串 i:整数 d:小数
//	mysqli_stmt_bind_param($stmt,'i',$salary);
//	$salary = 1000;
	mysqli_stmt_execute($stmt);
}
mysqli_stmt_close($stmt);
mysqli_close($db);

运行实例 »

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


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