未定义的类常量' FETCH_ASSCOC'使用PDO连接数据库时

时间:2017-05-29 16:56:29

标签: php mysql database class pdo

这是一行,我收到错误:

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);

}

}

?>

0 个答案:

没有答案