Move Field classes to Rdbms namespace
[mediawiki.git] / includes / libs / rdbms / field / MySQLField.php
blob709c61eb2df3e2a85779d402e7b5a11dca68d865
1 <?php
3 namespace Wikimedia\Rdbms;
5 class MySQLField implements Field {
6 private $name, $tablename, $default, $max_length, $nullable,
7 $is_pk, $is_unique, $is_multiple, $is_key, $type, $binary,
8 $is_numeric, $is_blob, $is_unsigned, $is_zerofill;
10 function __construct( $info ) {
11 $this->name = $info->name;
12 $this->tablename = $info->table;
13 $this->default = $info->def;
14 $this->max_length = $info->max_length;
15 $this->nullable = !$info->not_null;
16 $this->is_pk = $info->primary_key;
17 $this->is_unique = $info->unique_key;
18 $this->is_multiple = $info->multiple_key;
19 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
20 $this->type = $info->type;
21 $this->binary = isset( $info->binary ) ? $info->binary : false;
22 $this->is_numeric = isset( $info->numeric ) ? $info->numeric : false;
23 $this->is_blob = isset( $info->blob ) ? $info->blob : false;
24 $this->is_unsigned = isset( $info->unsigned ) ? $info->unsigned : false;
25 $this->is_zerofill = isset( $info->zerofill ) ? $info->zerofill : false;
28 /**
29 * @return string
31 function name() {
32 return $this->name;
35 /**
36 * @return string
38 function tableName() {
39 return $this->tablename;
42 /**
43 * @return string
45 function type() {
46 return $this->type;
49 /**
50 * @return bool
52 function isNullable() {
53 return $this->nullable;
56 function defaultValue() {
57 return $this->default;
60 /**
61 * @return bool
63 function isKey() {
64 return $this->is_key;
67 /**
68 * @return bool
70 function isMultipleKey() {
71 return $this->is_multiple;
74 /**
75 * @return bool
77 function isBinary() {
78 return $this->binary;
81 /**
82 * @return bool
84 function isNumeric() {
85 return $this->is_numeric;
88 /**
89 * @return bool
91 function isBlob() {
92 return $this->is_blob;
95 /**
96 * @return bool
98 function isUnsigned() {
99 return $this->is_unsigned;
103 * @return bool
105 function isZerofill() {
106 return $this->is_zerofill;