这是一行,我收到错误:
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSCOC,
有完整的代码:
<?php
class CON {
public static function db() {
$host = "127.0.0.1";
$db = "4";
$user = "danny";
$password = "censored";
$charset = "utf8";
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSCOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($dsn, $user, $pass, $opt);
}
}
?>