<?php
//1.创建mysqli对象
$mysqli=new MySQLi("localhost","root","root","test");
$sql="select balance from account where id>?";
$id=2;
//2.创建预编译对象
$mysqli_stmt=$mysqli->prepare($sql) or die($mysql->error);
//绑定参数
$mysqli_stmt->bind_param("i",$id);
//绑定结果集ec
$mysqli_stmt->bind_result($balance);
$mysqli_stmt->execute();
//取出绑定的值
while($mysqli_stmt->fetch()){
echo "<br/>--$balance";
}
//关闭资源
//释放结果
$mysqli_stmt->free_result();
//关闭预编译语句
$mysqli_stmt->close();
//关闭连接
$mysqli->close();
?>
12-预编译执行dql语句
最新推荐文章于 2022-06-14 19:13:59 发布