SubPartition.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * Library for extracting information about the sub-partitions
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin;
  7. /**
  8. * Represents a sub partition of a table
  9. */
  10. class SubPartition
  11. {
  12. /** @var string the database */
  13. protected $db;
  14. /** @var string the table */
  15. protected $table;
  16. /** @var string partition name */
  17. protected $name;
  18. /** @var int ordinal */
  19. protected $ordinal;
  20. /** @var string partition method */
  21. protected $method;
  22. /** @var string partition expression */
  23. protected $expression;
  24. /** @var int no of table rows in the partition */
  25. protected $rows;
  26. /** @var int data length */
  27. protected $dataLength;
  28. /** @var int index length */
  29. protected $indexLength;
  30. /** @var string partition comment */
  31. protected $comment;
  32. /**
  33. * Constructs a partition
  34. *
  35. * @param array $row fetched row from information_schema.PARTITIONS
  36. */
  37. public function __construct(array $row)
  38. {
  39. $this->db = $row['TABLE_SCHEMA'];
  40. $this->table = $row['TABLE_NAME'];
  41. $this->loadData($row);
  42. }
  43. /**
  44. * Loads data from the fetched row from information_schema.PARTITIONS
  45. *
  46. * @param array $row fetched row
  47. *
  48. * @return void
  49. */
  50. protected function loadData(array $row)
  51. {
  52. $this->name = $row['SUBPARTITION_NAME'];
  53. $this->ordinal = $row['SUBPARTITION_ORDINAL_POSITION'];
  54. $this->method = $row['SUBPARTITION_METHOD'];
  55. $this->expression = $row['SUBPARTITION_EXPRESSION'];
  56. $this->loadCommonData($row);
  57. }
  58. /**
  59. * Loads some data that is common to both partitions and sub partitions
  60. *
  61. * @param array $row fetched row
  62. *
  63. * @return void
  64. */
  65. protected function loadCommonData(array $row)
  66. {
  67. $this->rows = $row['TABLE_ROWS'];
  68. $this->dataLength = $row['DATA_LENGTH'];
  69. $this->indexLength = $row['INDEX_LENGTH'];
  70. $this->comment = $row['PARTITION_COMMENT'];
  71. }
  72. /**
  73. * Return the partition name
  74. *
  75. * @return string partition name
  76. */
  77. public function getName()
  78. {
  79. return $this->name;
  80. }
  81. /**
  82. * Return the ordinal of the partition
  83. *
  84. * @return int the ordinal
  85. */
  86. public function getOrdinal()
  87. {
  88. return $this->ordinal;
  89. }
  90. /**
  91. * Returns the partition method
  92. *
  93. * @return string partition method
  94. */
  95. public function getMethod()
  96. {
  97. return $this->method;
  98. }
  99. /**
  100. * Returns the partition expression
  101. *
  102. * @return string partition expression
  103. */
  104. public function getExpression()
  105. {
  106. return $this->expression;
  107. }
  108. /**
  109. * Returns the number of data rows
  110. *
  111. * @return int number of rows
  112. */
  113. public function getRows()
  114. {
  115. return $this->rows;
  116. }
  117. /**
  118. * Returns the data length
  119. *
  120. * @return int data length
  121. */
  122. public function getDataLength()
  123. {
  124. return $this->dataLength;
  125. }
  126. /**
  127. * Returns the index length
  128. *
  129. * @return int index length
  130. */
  131. public function getIndexLength()
  132. {
  133. return $this->indexLength;
  134. }
  135. /**
  136. * Returns the partition comment
  137. *
  138. * @return string partition comment
  139. */
  140. public function getComment()
  141. {
  142. return $this->comment;
  143. }
  144. }