<?php
header("Content-type:text/html;charset=utf-8");
$dsn = "mysql:host=localhost;dbname=test";
$pdo = new PDO($dsn, 'root', 'root');
$pdo->exec("set names utf8");
$sql="SELECT * FROM user where id>:id";
$stmt=$pdo->prepare($sql);//创建预处理对象
$id=1;
$stmt->bindParam(":id",$id);//参数赋值
$stmt->execute();//执行预处理
$data=$stmt->fetchAll(PDO::FETCH_ASSOC);//获取所有结果码片
mysql PDO预处理
最新推荐文章于 2023-05-14 08:32:34 发布