2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Creates the database interface required for database interactions
5 * and add it to GLOBALS.
7 * @package PhpMyAdmin-DBI
9 if (! defined('PHPMYADMIN')) {
13 require_once 'libraries/di/Container.class.php';
14 require_once 'libraries/DatabaseInterface.class.php';
16 if (defined('TESTSUITE')) {
18 * For testsuite we use dummy driver which can fake some queries.
20 include_once './libraries/dbi/DBIDummy.class.php';
21 $extension = new PMA_DBI_Dummy();
25 * First check for the mysqli extension, as it's the one recommended
26 * for the MySQL server's version that we support
27 * (if PHP 7+, it's the only one supported)
29 $extension = 'mysqli';
30 if (! PMA_DatabaseInterface
::checkDbExtension($extension)) {
32 $docurl = PMA_Util
::getDocuLink('faq', 'faqmysql');
34 __('See %sour documentation%s for more information.'),
35 '[a@' . $docurl . '@documentation]',
39 if (PMA_PHP_INT_VERSION
< 70000) {
41 if (! PMA_DatabaseInterface
::checkDbExtension($extension)) {
42 // warn about both extensions missing and exit
43 PMA_warnMissingExtension(
48 } elseif (empty($_SESSION['mysqlwarning'])) {
51 'You are using the mysql extension which is deprecated in '
52 . 'phpMyAdmin. Please consider installing the mysqli '
57 // tell the user just once per session
58 $_SESSION['mysqlwarning'] = true;
61 // mysql extension is not part of PHP 7+, so warn and exit
62 PMA_warnMissingExtension(
71 * Including The DBI Plugin
75 include_once './libraries/dbi/DBIMysql.class.php';
76 $extension = new PMA_DBI_Mysql();
79 include_once './libraries/dbi/DBIMysqli.class.php';
80 $extension = new PMA_DBI_Mysqli();
84 $GLOBALS['dbi'] = new PMA_DatabaseInterface($extension);
86 $container = \PMA\DI\Container
::getDefaultContainer();
87 $container->set('PMA_DatabaseInterface', $GLOBALS['dbi']);
88 $container->alias('dbi', 'PMA_DatabaseInterface');