使用PDO連接mysql的格式: $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);
2016-04-14
可以使用mysqlnd和mysql mysqli pdo_mysql
使用PDO連接mysql的格式:
$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);