Partition.class.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Library for extracting information about the partitions
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * base Partition Class
  13. *
  14. * @package PhpMyAdmin
  15. */
  16. class PMA_Partition
  17. {
  18. /**
  19. * returns array of partition names for a specific db/table
  20. *
  21. * @param string $db database name
  22. * @param string $table table name
  23. *
  24. * @access public
  25. * @return array of partition names
  26. */
  27. static public function getPartitionNames($db, $table)
  28. {
  29. if (PMA_Partition::havePartitioning()) {
  30. return $GLOBALS['dbi']->fetchResult(
  31. "SELECT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`"
  32. . " WHERE `TABLE_SCHEMA` = '" . $db
  33. . "' AND `TABLE_NAME` = '" . $table . "'"
  34. );
  35. } else {
  36. return array();
  37. }
  38. }
  39. /**
  40. * checks if MySQL server supports partitioning
  41. *
  42. * @static
  43. * @staticvar boolean $have_partitioning
  44. * @staticvar boolean $already_checked
  45. * @access public
  46. * @return boolean
  47. */
  48. static public function havePartitioning()
  49. {
  50. static $have_partitioning = false;
  51. static $already_checked = false;
  52. if (! $already_checked) {
  53. if (PMA_MYSQL_INT_VERSION >= 50100) {
  54. if (PMA_MYSQL_INT_VERSION < 50600) {
  55. if ($GLOBALS['dbi']->fetchValue(
  56. "SHOW VARIABLES LIKE 'have_partitioning';"
  57. )) {
  58. $have_partitioning = true;
  59. }
  60. } else {
  61. // see http://dev.mysql.com/doc/refman/5.6/en/partitioning.html
  62. $plugins = $GLOBALS['dbi']->fetchResult("SHOW PLUGINS");
  63. foreach ($plugins as $value) {
  64. if ($value['Name'] == 'partition') {
  65. $have_partitioning = true;
  66. break;
  67. }
  68. }
  69. }
  70. $already_checked = true;
  71. }
  72. }
  73. return $have_partitioning;
  74. }
  75. }
  76. ?>