$host = 'localhost';$charset = 'utf8';$dbname = 'dsw';$user = 'root';$password = 'root';$dsn = sprintf('mysql:host=%s;dbname=%s;charset:%s',$host,$dbname,$charset);1、链接数据库$pdo = new PDO($dsn,$user,$password);2、查询操作$sql = "select * form table where id=?";$stmt = $pdo->prepare($sql);$stmt->bindValue($id);$stmt->execute();
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号