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;
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->nullable = !$info->not_null;
27 $this->is_pk = $info->primary_key;
28 $this->is_unique = $info->unique_key;
29 $this->is_multiple = $info->multiple_key;
30 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
31 $this->type = $info->type;
32 $this->binary = $info->binary ?? false;
33 $this->is_numeric = $info->numeric ?? false;
34 $this->is_blob = $info->blob ?? false;
35 $this->is_unsigned = $info->unsigned ?? false;
36 $this->is_zerofill = $info->zerofill ?? false;
37 }
38
42 public function name() {
43 return $this->name;
44 }
45
49 public function tableName() {
50 return $this->tablename;
51 }
52
56 public function type() {
57 return $this->type;
58 }
59
63 public function isNullable() {
64 return $this->nullable;
65 }
66
67 public function defaultValue() {
68 return $this->default;
69 }
70
74 public function isKey() {
75 return $this->is_key;
76 }
77
81 public function isMultipleKey() {
82 return $this->is_multiple;
83 }
84
88 public function isBinary() {
89 return $this->binary;
90 }
91
95 public function isNumeric() {
96 return $this->is_numeric;
97 }
98
102 public function isBlob() {
103 return $this->is_blob;
104 }
105
109 public function isUnsigned() {
110 return $this->is_unsigned;
111 }
112
116 public function isZerofill() {
117 return $this->is_zerofill;
118 }
119}
Base for all database-specific classes representing information about database fields.
Definition Field.php:9