File: MySQLField.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (122 lines) | stat: -rw-r--r-- 2,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php

namespace Wikimedia\Rdbms;

class MySQLField implements Field {
	private string $name;
	private string $tablename;
	/** @var mixed */
	private $default;
	/** @var int */
	private $max_length;
	private bool $nullable;
	private bool $is_pk;
	private bool $is_unique;
	private bool $is_multiple;
	private bool $is_key;
	private string $type;
	private bool $binary;
	private bool $is_numeric;
	private bool $is_blob;
	private bool $is_unsigned;
	private bool $is_zerofill;

	public function __construct( $info ) {
		$this->name = $info->name;
		$this->tablename = $info->table;
		$this->default = $info->def;
		$this->max_length = $info->max_length;
		$this->nullable = !$info->not_null;
		$this->is_pk = $info->primary_key;
		$this->is_unique = $info->unique_key;
		$this->is_multiple = $info->multiple_key;
		$this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
		$this->type = $info->type;
		$this->binary = $info->binary ?? false;
		$this->is_numeric = $info->numeric ?? false;
		$this->is_blob = $info->blob ?? false;
		$this->is_unsigned = $info->unsigned ?? false;
		$this->is_zerofill = $info->zerofill ?? false;
	}

	/**
	 * @return string
	 */
	public function name() {
		return $this->name;
	}

	/**
	 * @return string
	 */
	public function tableName() {
		return $this->tablename;
	}

	/**
	 * @return string
	 */
	public function type() {
		return $this->type;
	}

	/**
	 * @return bool
	 */
	public function isNullable() {
		return $this->nullable;
	}

	public function defaultValue() {
		return $this->default;
	}

	/**
	 * @return bool
	 */
	public function isKey() {
		return $this->is_key;
	}

	/**
	 * @return bool
	 */
	public function isMultipleKey() {
		return $this->is_multiple;
	}

	/**
	 * @return bool
	 */
	public function isBinary() {
		return $this->binary;
	}

	/**
	 * @return bool
	 */
	public function isNumeric() {
		return $this->is_numeric;
	}

	/**
	 * @return bool
	 */
	public function isBlob() {
		return $this->is_blob;
	}

	/**
	 * @return bool
	 */
	public function isUnsigned() {
		return $this->is_unsigned;
	}

	/**
	 * @return bool
	 */
	public function isZerofill() {
		return $this->is_zerofill;
	}
}