1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plasma Driver MySQL component |
4
|
|
|
* Copyright 2018-2019 PlasmaPHP, All Rights Reserved |
5
|
|
|
* |
6
|
|
|
* Website: https://github.com/PlasmaPHP |
7
|
|
|
* License: https://github.com/PlasmaPHP/driver-mysql/blob/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Plasma\Drivers\MySQL; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Column Definitions define columns (who would've thought of that?). Such as their name, type, length, etc. |
14
|
|
|
*/ |
15
|
|
|
class ColumnDefinition extends \Plasma\AbstractColumnDefinition { |
16
|
|
|
/** |
17
|
|
|
* Whether the column is nullable (not `NOT NULL`). |
18
|
|
|
* @return bool |
19
|
|
|
*/ |
20
|
2 |
|
function isNullable(): bool { |
21
|
2 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::NOT_NULL_FLAG) !== 0); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Whether the column is auto incremented. |
26
|
|
|
* @return bool |
27
|
|
|
*/ |
28
|
2 |
|
function isAutoIncrement(): bool { |
29
|
2 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::AUTO_INCREMENT_FLAG) !== 0); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Whether the column is the primary key. |
34
|
|
|
* @return bool |
35
|
|
|
*/ |
36
|
2 |
|
function isPrimaryKey(): bool { |
37
|
2 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::PRI_KEY_FLAG) !== 0); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Whether the column is the unique key. |
42
|
|
|
* @return bool |
43
|
|
|
*/ |
44
|
2 |
|
function isUniqueKey(): bool { |
45
|
2 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::UNIQUE_KEY_FLAG) !== 0); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Whether the column is part of a multiple/composite key. |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
2 |
|
function isMultipleKey(): bool { |
53
|
2 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::MULTIPLE_KEY_FLAG) !== 0); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Whether the column is unsigned (only makes sense for numeric types). |
58
|
|
|
* @return bool |
59
|
|
|
*/ |
60
|
9 |
|
function isUnsigned(): bool { |
61
|
9 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::UNSIGNED_FLAG) !== 0); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Whether the column gets zerofilled to the length. |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
9 |
|
function isZerofilled(): bool { |
69
|
9 |
|
return (($this->flags & \Plasma\Drivers\MySQL\FieldFlags::ZEROFILL_FLAG) !== 0); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|