MediaWiki master
MySQLField.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
5use stdClass;
6
7class MySQLField implements Field {
8 private string $name;
9 private string $tablename;
11 private $default;
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( stdClass $info ) {
25 $this->name = $info->name;
26 $this->tablename = $info->table;
27 $this->default = $info->def;
28 $this->nullable = !$info->not_null;
29 $this->is_pk = $info->primary_key;
30 $this->is_unique = $info->unique_key;
31 $this->is_multiple = $info->multiple_key;
32 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
33 $this->type = $info->type;
34 $this->binary = $info->binary ?? false;
35 $this->is_numeric = $info->numeric ?? false;
36 $this->is_blob = $info->blob ?? false;
37 $this->is_unsigned = $info->unsigned ?? false;
38 $this->is_zerofill = $info->zerofill ?? false;
39 }
40
44 public function name() {
45 return $this->name;
46 }
47
51 public function tableName() {
52 return $this->tablename;
53 }
54
58 public function type() {
59 return $this->type;
60 }
61
65 public function isNullable() {
66 return $this->nullable;
67 }
68
72 public function defaultValue() {
73 return $this->default;
74 }
75
79 public function isKey() {
80 return $this->is_key;
81 }
82
86 public function isMultipleKey() {
87 return $this->is_multiple;
88 }
89
93 public function isBinary() {
94 return $this->binary;
95 }
96
100 public function isNumeric() {
101 return $this->is_numeric;
102 }
103
107 public function isBlob() {
108 return $this->is_blob;
109 }
110
114 public function isUnsigned() {
115 return $this->is_unsigned;
116 }
117
121 public function isZerofill() {
122 return $this->is_zerofill;
123 }
124}
__construct(stdClass $info)
Base for all database-specific classes representing information about database fields.
Definition Field.php:9