MediaWiki master
MySQLField.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
5class MySQLField implements Field {
6 private string $name;
7 private string $tablename;
9 private $default;
11 private $max_length;
12 private bool $nullable;
13 private bool $is_pk;
14 private bool $is_unique;
15 private bool $is_multiple;
16 private bool $is_key;
17 private string $type;
18 private bool $binary;
19 private bool $is_numeric;
20 private bool $is_blob;
21 private bool $is_unsigned;
22 private bool $is_zerofill;
23
24 public function __construct( $info ) {
25 $this->name = $info->name;
26 $this->tablename = $info->table;
27 $this->default = $info->def;
28 $this->max_length = $info->max_length;
29 $this->nullable = !$info->not_null;
30 $this->is_pk = $info->primary_key;
31 $this->is_unique = $info->unique_key;
32 $this->is_multiple = $info->multiple_key;
33 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
34 $this->type = $info->type;
35 $this->binary = $info->binary ?? false;
36 $this->is_numeric = $info->numeric ?? false;
37 $this->is_blob = $info->blob ?? false;
38 $this->is_unsigned = $info->unsigned ?? false;
39 $this->is_zerofill = $info->zerofill ?? false;
40 }
41
45 public function name() {
46 return $this->name;
47 }
48
52 public function tableName() {
53 return $this->tablename;
54 }
55
59 public function type() {
60 return $this->type;
61 }
62
66 public function isNullable() {
67 return $this->nullable;
68 }
69
70 public function defaultValue() {
71 return $this->default;
72 }
73
77 public function isKey() {
78 return $this->is_key;
79 }
80
84 public function isMultipleKey() {
85 return $this->is_multiple;
86 }
87
91 public function isBinary() {
92 return $this->binary;
93 }
94
98 public function isNumeric() {
99 return $this->is_numeric;
100 }
101
105 public function isBlob() {
106 return $this->is_blob;
107 }
108
112 public function isUnsigned() {
113 return $this->is_unsigned;
114 }
115
119 public function isZerofill() {
120 return $this->is_zerofill;
121 }
122}
Base for all database-specific classes representing information about database fields.
Definition Field.php:9