3 declare(strict_types
=1);
9 use function preg_match
;
10 use function preg_replace
;
12 final class InsertEditColumn
14 public readonly
string|
null $default;
15 public readonly
string $md5;
17 * trueType contains only the type (stops at first bracket)
19 public readonly
string $trueType;
20 public readonly
string $pmaType;
21 public readonly
int $length;
22 public readonly
bool $firstTimestamp;
24 public function __construct(
25 public readonly
string $field,
26 public readonly
string $type,
27 public readonly
bool $isNull,
28 public readonly
string $key,
30 public readonly
string $extra,
32 public readonly
bool $isBinary,
33 public readonly
bool $isBlob,
34 public readonly
bool $isChar,
38 $this->type
=== 'datetime'
43 $this->default = date('Y-m-d H:i:s');
45 $this->default = $default;
48 $this->md5
= md5($this->field
);
49 $this->trueType
= preg_replace('@\(.*@s', '', $this->type
);
50 // length is unknown for geometry fields,
51 // make enough space to edit very simple WKTs
52 if ($columnLength === -1) {
56 $this->length
= preg_match('@float|double@', $this->type
) ?
100 : $columnLength;
57 $this->pmaType
= match ($this->trueType
) {
58 'set', 'enum' => $this->trueType
,
59 default => $this->type
,
62 * TODO: This property is useless at the moment.
63 * It seems like a long time ago before refactoring into classes,
64 * this kept track of how many timestamps are in the table.
66 $this->firstTimestamp
= $this->trueType
=== 'timestamp';