[Phpmyadmin-devel] failover for loading mysql(i) extension
Sebastian Mendel
lists at sebastianmendel.de
Wed Nov 16 09:29:01 CET 2005
Hi,
i have written a fail over for loading the desired extension,
should i check in this now, or should i wait for 2.7.1 ?
if selected extension it trys the other extension, and prints an error
message on main.php, but works, elsewise it redirects to error.php
(also minor changes in main.php and dbi/*)
in database_interface.lib.php:
/**
* Loads the mysql extensions if it is not loaded yet
*
* @param string $extension mysql extension to load
*/
function PMA_DBI_checkAndLoadMysqlExtension( $extension = 'mysql' ) {
if ( ! function_exists( $extension . '_connect' ) ) {
PMA_dl( $extension );
// check whether mysql is available
if ( ! function_exists( $extension . '_connect' ) ) {
return false;
}
}
return true;
}
/**
* check for requested extension
*/
if ( ! PMA_DBI_checkAndLoadMysqlExtension(
$GLOBALS['cfg']['Server']['extension'] ) ) {
// if it fails try alternative extension ...
// and display an error ...
// TODO 2.7.1: add different messages for alternativ extension
// and complete fail (no alternativ extension too)
$GLOBALS['errors'][] = sprintf($GLOBALS['strCantLoad'],
$GLOBALS['cfg']['Server']['extension']) . '<br />' . "\n"
.'<a href="./Documentation.html#faqmysql"
target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
if ( $GLOBALS['cfg']['Server']['extension'] === 'mysql' ) {
$alternativ_extension = 'mysqli';
} else {
$alternativ_extension = 'mysql';
}
if ( ! PMA_DBI_checkAndLoadMysqlExtension( $alternativ_extension ) ) {
// if alternativ fails too ...
header( 'Location: error.php'
. '?lang=' . urlencode( $available_languages[$lang][2] )
. '&char=' . urlencode( $charset )
. '&dir=' . urlencode( $text_dir )
. '&type=' . urlencode( $strError )
. '&error=' . urlencode(
sprintf( $GLOBALS['strCantLoad'],
$GLOBALS['cfg']['Server']['extension'] )
.' - [a at ./Documentation.html#faqmysql at documentation]'
.$GLOBALS['strDocu'] . '[/a]' )
. '&' . SID
);
exit();
}
$GLOBALS['cfg']['Server']['extension'] = $alternativ_extension;
}
--
Sebastian Mendel
www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet
More information about the Developers
mailing list