Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / libs / rdbms / field / MySQLField.php
1 <?php
2 class MySQLField implements Field {
3 private $name, $tablename, $default, $max_length, $nullable,
4 $is_pk, $is_unique, $is_multiple, $is_key, $type, $binary,
5 $is_numeric, $is_blob, $is_unsigned, $is_zerofill;
6
7 function __construct( $info ) {
8 $this->name = $info->name;
9 $this->tablename = $info->table;
10 $this->default = $info->def;
11 $this->max_length = $info->max_length;
12 $this->nullable = !$info->not_null;
13 $this->is_pk = $info->primary_key;
14 $this->is_unique = $info->unique_key;
15 $this->is_multiple = $info->multiple_key;
16 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
17 $this->type = $info->type;
18 $this->binary = isset( $info->binary ) ? $info->binary : false;
19 $this->is_numeric = isset( $info->numeric ) ? $info->numeric : false;
20 $this->is_blob = isset( $info->blob ) ? $info->blob : false;
21 $this->is_unsigned = isset( $info->unsigned ) ? $info->unsigned : false;
22 $this->is_zerofill = isset( $info->zerofill ) ? $info->zerofill : false;
23 }
24
25 /**
26 * @return string
27 */
28 function name() {
29 return $this->name;
30 }
31
32 /**
33 * @return string
34 */
35 function tableName() {
36 return $this->tablename;
37 }
38
39 /**
40 * @return string
41 */
42 function type() {
43 return $this->type;
44 }
45
46 /**
47 * @return bool
48 */
49 function isNullable() {
50 return $this->nullable;
51 }
52
53 function defaultValue() {
54 return $this->default;
55 }
56
57 /**
58 * @return bool
59 */
60 function isKey() {
61 return $this->is_key;
62 }
63
64 /**
65 * @return bool
66 */
67 function isMultipleKey() {
68 return $this->is_multiple;
69 }
70
71 /**
72 * @return bool
73 */
74 function isBinary() {
75 return $this->binary;
76 }
77
78 /**
79 * @return bool
80 */
81 function isNumeric() {
82 return $this->is_numeric;
83 }
84
85 /**
86 * @return bool
87 */
88 function isBlob() {
89 return $this->is_blob;
90 }
91
92 /**
93 * @return bool
94 */
95 function isUnsigned() {
96 return $this->is_unsigned;
97 }
98
99 /**
100 * @return bool
101 */
102 function isZerofill() {
103 return $this->is_zerofill;
104 }
105 }
106