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 use PMA\libraries\dbi\DBIDummy
;
10 use PMA\libraries\di\Container
;
11 use PMA\libraries\DatabaseInterface
;
12 use PMA\libraries\dbi\DBIMysql
;
13 use PMA\libraries\dbi\DBIMysqli
;
15 if (! defined('PHPMYADMIN')) {
19 if (defined('TESTSUITE')) {
21 * For testsuite we use dummy driver which can fake some queries.
23 $extension = new DBIDummy();
27 * First check for the mysqli extension, as it's the one recommended
28 * for the MySQL server's version that we support
29 * (if PHP 7+, it's the only one supported)
31 $extension = 'mysqli';
32 if (!DatabaseInterface
::checkDbExtension($extension)) {
34 $docurl = PMA\libraries\Util
::getDocuLink('faq', 'faqmysql');
36 __('See %sour documentation%s for more information.'),
37 '[a@' . $docurl . '@documentation]',
41 if (PHP_VERSION_ID
< 70000) {
43 if (! PMA\libraries\DatabaseInterface
::checkDbExtension($extension)) {
44 // warn about both extensions missing and exit
45 PMA_warnMissingExtension(
50 } elseif (empty($_SESSION['mysqlwarning'])) {
53 'You are using the mysql extension which is deprecated in '
54 . 'phpMyAdmin. Please consider installing the mysqli '
59 // tell the user just once per session
60 $_SESSION['mysqlwarning'] = true;
63 // mysql extension is not part of PHP 7+, so warn and exit
64 PMA_warnMissingExtension(
73 * Including The DBI Plugin
77 $extension = new DBIMysql();
80 include_once 'libraries/dbi/DBIMysqli.lib.php';
81 $extension = new DBIMysqli();
85 $GLOBALS['dbi'] = new DatabaseInterface($extension);
87 $container = Container
::getDefaultContainer();
88 $container->set('PMA_DatabaseInterface', $GLOBALS['dbi']);
89 $container->alias('dbi', 'PMA_DatabaseInterface');