# HG changeset patch # User Dan Fuhry # Date 1377139834 14400 # Node ID e58294b867c18e7134137c6024da2f4e0ce086e8 # Parent fa2b0825bbc535d3e3e9828eb292f098e0f1a5bb Add transparent support for PDO into installer; further integration of PDO diff -r fa2b0825bbc5 -r e58294b867c1 includes/common.php --- a/includes/common.php Wed Aug 21 22:34:54 2013 -0400 +++ b/includes/common.php Wed Aug 21 22:50:34 2013 -0400 @@ -217,7 +217,9 @@ if ( !isset($dbdriver) ) $dbdriver = 'mysql'; -$db = new $dbdriver(); +$dbdriver_cls = have_pdo($dbdriver) ? "{$dbdriver}_pdo" : $dbdriver; + +$db = new $dbdriver_cls(); $db->connect(); profiler_log('Database connected'); diff -r fa2b0825bbc5 -r e58294b867c1 includes/common_cli.php --- a/includes/common_cli.php Wed Aug 21 22:34:54 2013 -0400 +++ b/includes/common_cli.php Wed Aug 21 22:50:34 2013 -0400 @@ -36,7 +36,9 @@ if ( !isset($dbdriver) ) $dbdriver = 'mysql'; -$db = new $dbdriver(); +$dbdriver_cls = have_pdo($dbdriver) ? "{$dbdriver}_pdo" : $dbdriver; + +$db = new $dbdriver_cls(); $db->connect(); profiler_log('Database connected'); diff -r fa2b0825bbc5 -r e58294b867c1 includes/dbal.php --- a/includes/dbal.php Wed Aug 21 22:34:54 2013 -0400 +++ b/includes/dbal.php Wed Aug 21 22:50:34 2013 -0400 @@ -32,6 +32,17 @@ echo "$errtype: $errstr
Error source:
$debug
"; } +/** + * Checks to see if a given pdo driver is available. + * @param string driver name + * @return bool + */ + +function have_pdo($driver) +{ + return class_exists('PDO') && extension_loaded("pdo_$driver") && class_exists("{$driver}_pdo"); +} + global $db_sql_parse_time; $db_sql_parse_time = 0; @@ -40,7 +51,7 @@ var $row = array(); var $rowset = array(); var $errhandler; - var $dbms_name = 'MySQL'; + var $dbms_name = 'MySQL (legacy)'; /** * Get a flat textual list of queries that have been made. @@ -706,7 +717,7 @@ var $row = array(); var $rowset = array(); var $errhandler; - var $dbms_name = 'MySQL'; + var $dbms_name = 'MySQL/PDO'; /** * Get a flat textual list of queries that have been made. diff -r fa2b0825bbc5 -r e58294b867c1 install/includes/stages/database.php --- a/install/includes/stages/database.php Wed Aug 21 22:34:54 2013 -0400 +++ b/install/includes/stages/database.php Wed Aug 21 22:50:34 2013 -0400 @@ -27,7 +27,7 @@ $pgsql_disable_reason = ''; $mysql_disable = ''; $pgsql_disable = ''; -if ( !function_exists('mysql_connect') ) +if ( !function_exists('mysql_connect') && !have_pdo("mysql") ) { $mysql_disable = ' disabled="disabled"'; $mysql_disable_reason = $lang->get('database_driver_err_no_mysql'); diff -r fa2b0825bbc5 -r e58294b867c1 install/includes/stages/install.php --- a/install/includes/stages/install.php Wed Aug 21 22:34:54 2013 -0400 +++ b/install/includes/stages/install.php Wed Aug 21 22:50:34 2013 -0400 @@ -29,7 +29,9 @@ return true; } -$db = new $dbdriver(); +$dbdriver_cls = have_pdo($dbdriver) ? "{$dbdriver}_pdo" : $dbdriver; + +$db = new $dbdriver_cls(); $result = $db->connect(); if ( !$result ) { diff -r fa2b0825bbc5 -r e58294b867c1 language/english/core.json --- a/language/english/core.json Wed Aug 21 22:34:54 2013 -0400 +++ b/language/english/core.json Wed Aug 21 22:50:34 2013 -0400 @@ -46,6 +46,7 @@ enano_about_lbl_webserver: 'Web server:', enano_about_lbl_serverplatform: 'Server platform:', enano_about_lbl_phpversion: 'PHP version:', + enano_about_lbl_dbdriver: 'Database driver:', enano_about_lbl_mysqlversion: 'MySQL version:', enano_about_lbl_pgsqlversion: 'PostgreSQL version:', direction: 'ltr' diff -r fa2b0825bbc5 -r e58294b867c1 plugins/SpecialPageFuncs.php --- a/plugins/SpecialPageFuncs.php Wed Aug 21 22:34:54 2013 -0400 +++ b/plugins/SpecialPageFuncs.php Wed Aug 21 22:50:34 2013 -0400 @@ -486,20 +486,21 @@ get('meta_enano_about_lbl_enanoversion'); ?> get('meta_enano_about_lbl_webserver'); ?> get('meta_enano_about_lbl_serverplatform'); ?> - get('meta_enano_about_lbl_phpversion'); ?> + get('meta_enano_about_lbl_dbdriver'); ?>dbms_name; ?> + get('meta_enano_about_lbl_phpversion'); ?> - get('meta_enano_about_lbl_mysqlversion'); ?>get_server_version(); ?> + get('meta_enano_about_lbl_mysqlversion'); ?>get_server_version(); ?> _conn); $pg_version = $pg_serverdata['server']; ?> - get('meta_enano_about_lbl_pgsqlversion'); ?> + get('meta_enano_about_lbl_pgsqlversion'); ?>