| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\Rdbms; |
| 4 |
|
| 5 |
class MySQLField implements Field { |
| 6 |
private string $name; |
| 7 |
private string $tablename; |
| 8 |
|
| 9 |
private $default; |
| 10 |
|
| 11 |
private $max_length; |
| 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( $info ) { |
| 25 |
$this->name = $info->name; |
| 26 |
$this->tablename = $info->table; |
| 27 |
$this->default = $info->def; |
| 28 |
$this->max_length = $info->max_length; |
| 29 |
$this->nullable = !$info->not_null; |
| 30 |
$this->is_pk = $info->primary_key; |
| 31 |
$this->is_unique = $info->unique_key; |
| 32 |
$this->is_multiple = $info->multiple_key; |
| 33 |
$this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple ); |
| 34 |
$this->type = $info->type; |
| 35 |
$this->binary = $info->binary ?? false; |
| 36 |
$this->is_numeric = $info->numeric ?? false; |
| 37 |
$this->is_blob = $info->blob ?? false; |
| 38 |
$this->is_unsigned = $info->unsigned ?? false; |
| 39 |
$this->is_zerofill = $info->zerofill ?? false; |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public function name() { |
| 46 |
return $this->name; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public function tableName() { |
| 53 |
return $this->tablename; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public function type() { |
| 60 |
return $this->type; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public function isNullable() { |
| 67 |
return $this->nullable; |
| 68 |
} |
| 69 |
|
| 70 |
public function defaultValue() { |
| 71 |
return $this->default; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
public function isKey() { |
| 78 |
return $this->is_key; |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public function isMultipleKey() { |
| 85 |
return $this->is_multiple; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
public function isBinary() { |
| 92 |
return $this->binary; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
public function isNumeric() { |
| 99 |
return $this->is_numeric; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public function isBlob() { |
| 106 |
return $this->is_blob; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public function isUnsigned() { |
| 113 |
return $this->is_unsigned; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
public function isZerofill() { |
| 120 |
return $this->is_zerofill; |
| 121 |
} |
| 122 |
} |