链接数据库
$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();