Translated using Weblate (Slovenian)
[phpmyadmin.git] / libraries / database_interface.inc.php
blobdef0b777be61f5b4a12998d7adef27c921346283
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Creates the database interface required for database interactions
5 * and add it to GLOBALS.
7 * @package PhpMyAdmin-DBI
8 */
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')) {
16 exit;
19 if (defined('TESTSUITE')) {
20 /**
21 * For testsuite we use dummy driver which can fake some queries.
23 $extension = new DBIDummy();
24 } else {
26 /**
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');
35 $doclink = sprintf(
36 __('See %sour documentation%s for more information.'),
37 '[a@' . $docurl . '@documentation]',
38 '[/a]'
41 if (PHP_VERSION_ID < 70000) {
42 $extension = 'mysql';
43 if (! PMA\libraries\DatabaseInterface::checkDbExtension($extension)) {
44 // warn about both extensions missing and exit
45 PMA_warnMissingExtension(
46 'mysqli',
47 true,
48 $doclink
50 } elseif (empty($_SESSION['mysqlwarning'])) {
51 trigger_error(
52 __(
53 'You are using the mysql extension which is deprecated in '
54 . 'phpMyAdmin. Please consider installing the mysqli '
55 . 'extension.'
56 ) . ' ' . $doclink,
57 E_USER_WARNING
59 // tell the user just once per session
60 $_SESSION['mysqlwarning'] = true;
62 } else {
63 // mysql extension is not part of PHP 7+, so warn and exit
64 PMA_warnMissingExtension(
65 'mysqli',
66 true,
67 $doclink
72 /**
73 * Including The DBI Plugin
75 switch($extension) {
76 case 'mysql' :
77 $extension = new DBIMysql();
78 break;
79 case 'mysqli' :
80 include_once 'libraries/dbi/DBIMysqli.lib.php';
81 $extension = new DBIMysqli();
82 break;
85 $GLOBALS['dbi'] = new DatabaseInterface($extension);
87 $container = Container::getDefaultContainer();
88 $container->set('PMA_DatabaseInterface', $GLOBALS['dbi']);
89 $container->alias('dbi', 'PMA_DatabaseInterface');