升级到php 5.3.x后,PDO类未发现致命错误

时间:2012-07-18 04:34:40

标签: php mysql pdo

我们进行了服务器升级,我们从5.2.x移动到php 5.3.x.我是mysql pdo,下面的代码showen在升级之前工作。

    <?php

error_reporting(E_ALL);
ini_set('display_errors', '1');


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Database user / pass
 */
$sql_details = array(
    "user" => "",
    "pass" => "",
    "host" => "",
    "db" => ""
);


// This is included for the development and deploy environment used on the DataTables
// server. You can delete this block - it just includes my own user/pass without making 
// them public!
if ( is_file($_SERVER['DOCUMENT_ROOT']."/datatables/pdo.php") ) {
    include( $_SERVER['DOCUMENT_ROOT']."/datatables/pdo.php" );
}
// /End development include


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Database connection
 */

/* PDO connection */
$db = new PDO(
    "mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
    $sql_details['user'],
    $sql_details['pass'],
    array(
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
    )
);

/* mysql_* connection */
/*
if ( ! $db = mysql_pconnect( $sql_details['host'], $sql_details['user'], $sql_details['pass'] ) ) {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not open connection to server' );
}

if ( ! mysql_select_db( $sql_details['db'], $db ) ) {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not select database' );
}
*/

但升级后,我收到了PDO类未找到的致命错误。我检查ht php.ini并启用了pdo。以下是php.ini的片段。

'--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-sqlite=shared' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'
pdo_mysql
pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
pdo_sqlite

你能帮我解决这个问题吗?

提前致谢, 作者Srini。

1 个答案:

答案 0 :(得分:1)

你的phpinfo表没有显示PDO部分和pdo_mysql部分,这意味着你没有安装pdo.Like我的phpinfo显示..see image phpinfo