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;
8 private $default;
9 private $max_length;
10 private bool $nullable;
11 private bool $is_pk;
12 private bool $is_unique;
13 private bool $is_multiple;
14 private bool $is_key;
15 private string $type;
16 private bool $binary;
17 private bool $is_numeric;
18 private bool $is_blob;
19 private bool $is_unsigned;
20 private bool $is_zerofill;
21
22 public function __construct( $info ) {
23 $this->name = $info->name;
24 $this->tablename = $info->table;
25 $this->default = $info->def;
26 $this->max_length = $info->max_length;
27 $this->nullable = !$info->not_null;
28 $this->is_pk = $info->primary_key;
29 $this->is_unique = $info->unique_key;
30 $this->is_multiple = $info->multiple_key;
31 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
32 $this->type = $info->type;
33 $this->binary = $info->binary ?? false;
34 $this->is_numeric = $info->numeric ?? false;
35 $this->is_blob = $info->blob ?? false;
36 $this->is_unsigned = $info->unsigned ?? false;
37 $this->is_zerofill = $info->zerofill ?? false;
38 }
39
43 public function name() {
44 return $this->name;
45 }
46
50 public function tableName() {
51 return $this->tablename;
52 }
53
57 public function type() {
58 return $this->type;
59 }
60
64 public function isNullable() {
65 return $this->nullable;
66 }
67
68 public function defaultValue() {
69 return $this->default;
70 }
71
75 public function isKey() {
76 return $this->is_key;
77 }
78
82 public function isMultipleKey() {
83 return $this->is_multiple;
84 }
85
89 public function isBinary() {
90 return $this->binary;
91 }
92
96 public function isNumeric() {
97 return $this->is_numeric;
98 }
99
103 public function isBlob() {
104 return $this->is_blob;
105 }
106
110 public function isUnsigned() {
111 return $this->is_unsigned;
112 }
113
117 public function isZerofill() {
118 return $this->is_zerofill;
119 }
120}
Base for all database-specific classes representing information about database fields.
Definition Field.php:9