Translated using Weblate (Armenian)
[phpmyadmin.git] / libraries / database_interface.inc.php
blob52968bb093d5fe22c307ae25af3e93df1ac8ea3a
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 if (! defined('PHPMYADMIN')) {
10 exit;
13 require_once 'libraries/di/Container.class.php';
14 require_once 'libraries/DatabaseInterface.class.php';
16 if (defined('TESTSUITE')) {
17 /**
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();
22 } else {
24 /**
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');
33 $doclink = sprintf(
34 __('See %sour documentation%s for more information.'),
35 '[a@' . $docurl . '@documentation]',
36 '[/a]'
39 if (PMA_PHP_INT_VERSION < 70000) {
40 $extension = 'mysql';
41 if (! PMA_DatabaseInterface::checkDbExtension($extension)) {
42 // warn about both extensions missing and exit
43 PMA_warnMissingExtension(
44 'mysqli|mysql',
45 true,
46 $doclink
48 } elseif (empty($_SESSION['mysqlwarning'])) {
49 trigger_error(
50 __(
51 'You are using the mysql extension which is deprecated in '
52 . 'phpMyAdmin. Please consider installing the mysqli '
53 . 'extension.'
54 ) . ' ' . $doclink,
55 E_USER_WARNING
57 // tell the user just once per session
58 $_SESSION['mysqlwarning'] = true;
60 } else {
61 // mysql extension is not part of PHP 7+, so warn and exit
62 PMA_warnMissingExtension(
63 'mysqli',
64 true,
65 $doclink
70 /**
71 * Including The DBI Plugin
73 switch($extension) {
74 case 'mysql' :
75 include_once './libraries/dbi/DBIMysql.class.php';
76 $extension = new PMA_DBI_Mysql();
77 break;
78 case 'mysqli' :
79 include_once './libraries/dbi/DBIMysqli.class.php';
80 $extension = new PMA_DBI_Mysqli();
81 break;
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');