21,886
社区成员
发帖
与我相关
我的任务
分享
<?php
phpinof();
?>
$pdo = new PDO('mysql:host=localhost;dbname=database_name;port=3306','用户名','密码');
$pdo->exec('set names utf8');
$stmt = $pdo->prepare("select * from table where id =:id");
$stmt->bindValue(':id',1,PDO::PARAM_INT);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rows = $pdo->query("select * from table where id = 1")->fetchAll(PDO::FETCH_ASSOC);