Translated using Weblate (Portuguese)
[phpmyadmin.git] / src / Partitioning / SubPartition.php
blobfa177a3c2bcc05768a09f9c75dbb4c81d1ee3960
1 <?php
2 /**
3 * Library for extracting information about the sub-partitions
4 */
6 declare(strict_types=1);
8 namespace PhpMyAdmin\Partitioning;
10 /**
11 * Represents a sub partition of a table
13 class SubPartition
15 protected string|null $name = null;
16 protected int|null $ordinal = null;
17 protected string|null $method = null;
18 protected string|null $expression = null;
19 protected int $rows = 0;
20 protected int $dataLength = 0;
21 protected int $indexLength = 0;
22 protected string $comment = '';
24 /**
25 * Constructs a partition
27 * @param mixed[] $row fetched row from information_schema.PARTITIONS
29 public function __construct(array $row)
31 $this->name = $row['SUBPARTITION_NAME'];
32 $this->ordinal = $row['SUBPARTITION_ORDINAL_POSITION'] !== null
33 ? (int) $row['SUBPARTITION_ORDINAL_POSITION'] : null;
34 $this->method = $row['SUBPARTITION_METHOD'];
35 $this->expression = $row['SUBPARTITION_EXPRESSION'];
36 $this->loadCommonData($row);
39 /**
40 * Loads some data that is common to both partitions and sub partitions
42 * @param mixed[] $row fetched row
44 protected function loadCommonData(array $row): void
46 $this->rows = (int) $row['TABLE_ROWS'];
47 $this->dataLength = (int) $row['DATA_LENGTH'];
48 $this->indexLength = (int) $row['INDEX_LENGTH'];
49 $this->comment = $row['PARTITION_COMMENT'];
52 /**
53 * Return the partition name
55 public function getName(): string|null
57 return $this->name;
60 /**
61 * Return the ordinal of the partition
63 public function getOrdinal(): int|null
65 return $this->ordinal;
68 /**
69 * Returns the partition method
71 public function getMethod(): string|null
73 return $this->method;
76 /**
77 * Returns the partition expression
79 public function getExpression(): string|null
81 return $this->expression;
84 /**
85 * Returns the number of data rows
87 public function getRows(): int
89 return $this->rows;
92 /**
93 * Returns the data length
95 public function getDataLength(): int
97 return $this->dataLength;
101 * Returns the index length
103 public function getIndexLength(): int
105 return $this->indexLength;
109 * Returns the partition comment
111 public function getComment(): string
113 return $this->comment;