SubPartition.php 3.5 KB

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