database_interface.inc.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Creates the database interface required for database interctions
  5. * and add it to GLOBALS.
  6. *
  7. * @package PhpMyAdmin-DBI
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. require_once './libraries/DatabaseInterface.class.php';
  13. if (defined('TESTSUITE')) {
  14. /**
  15. * For testsuite we use dummy driver which can fake some queries.
  16. */
  17. include_once './libraries/dbi/DBIDummy.class.php';
  18. $extension = new PMA_DBI_Dummy();
  19. } else {
  20. /**
  21. * First check for the mysqli extension, as it's the one recommended
  22. * for the MySQL server's version that we support
  23. */
  24. $extension = 'mysqli';
  25. if (! PMA_DatabaseInterface::checkDbExtension($extension)) {
  26. $docurl = PMA_Util::getDocuLink('faq', 'faqmysql');
  27. $doclink = sprintf(
  28. __('See %sour documentation%s for more information.'),
  29. '[a@' . $docurl . '@documentation]',
  30. '[/a]'
  31. );
  32. $extension = 'mysql';
  33. if (! PMA_DatabaseInterface::checkDbExtension($extension)) {
  34. // warn about both extensions missing and exit
  35. PMA_warnMissingExtension(
  36. 'mysqli|mysql',
  37. true,
  38. $doclink
  39. );
  40. } elseif (empty($_SESSION['mysqlwarning'])) {
  41. trigger_error(
  42. __(
  43. 'You are using the mysql extension which is deprecated in '
  44. . 'phpMyAdmin. Please consider installing the mysqli '
  45. . 'extension.'
  46. ) . ' ' . $doclink,
  47. E_USER_WARNING
  48. );
  49. // tell the user just once per session
  50. $_SESSION['mysqlwarning'] = true;
  51. }
  52. }
  53. /**
  54. * Including The DBI Plugin
  55. */
  56. switch($extension) {
  57. case 'mysql' :
  58. include_once './libraries/dbi/DBIMysql.class.php';
  59. $extension = new PMA_DBI_Mysql();
  60. break;
  61. case 'mysqli' :
  62. include_once './libraries/dbi/DBIMysqli.class.php';
  63. $extension = new PMA_DBI_Mysqli();
  64. break;
  65. }
  66. }
  67. $GLOBALS['dbi'] = new PMA_DatabaseInterface($extension);
  68. ?>