为什么问号而不是PDO中的文字?

时间:2017-11-13 01:21:50

标签: php mysql pdo

PHP 5.3.3

如果我尝试PDO,我会看到俄语文本,如#34; ?????? ?????????"

    $db = new PDO('mysql:host=' . $DBData['host'] . ';dbname=' . $DBData['base'] . ";charset=utf8;", 
        $DBData['user'], $DBData['pass'], array(
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES   => false,
        PDO::ATTR_PERSISTENT         => true
    ));

    $CONFIG = $db->query("SELECT * FROM `config`")->fetch();

如果我试试这个,我看到正常的文字:

    $db = mysql_connect($DBData['host'], $DBData['user'], $DBData['pass']);
    mysql_select_db($DBData['base'], $db);
    mysql_query('SET NAMES utf8', $db);          
    mysql_query('SET CHARACTER SET utf8', $db);  
    mysql_query('SET COLLATION_CONNECTION="utf8"', $db);

    $CONFIG = mysql_fetch_assoc( mysql_query("SELECT * FROM `config`") );

为什么PDO不起作用

0 个答案:

没有答案