1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Soluble\Db\Metadata\Column\Definition; |
4
|
|
|
|
5
|
|
|
class DecimalColumn extends AbstractColumnDefinition implements NumericColumnInterface |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* |
9
|
|
|
* @var int |
10
|
|
|
*/ |
11
|
|
|
protected $numericPrecision = null; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* |
15
|
|
|
* @var int |
16
|
|
|
*/ |
17
|
|
|
protected $numericScale = null; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* |
22
|
|
|
* @var boolean |
23
|
|
|
*/ |
24
|
|
|
protected $numericUnsigned = null; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return bool |
29
|
|
|
*/ |
30
|
|
|
public function getNumericUnsigned() |
31
|
|
|
{ |
32
|
|
|
return $this->numericUnsigned; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param bool $numericUnsigned |
37
|
|
|
* @return DecimalColumn |
38
|
|
|
*/ |
39
|
|
|
public function setNumericUnsigned($numericUnsigned) |
40
|
|
|
{ |
41
|
|
|
$this->numericUnsigned = $numericUnsigned; |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return bool |
48
|
|
|
*/ |
49
|
|
|
public function isNumericUnsigned() |
50
|
|
|
{ |
51
|
|
|
return $this->numericUnsigned; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Return the precision, for example |
56
|
|
|
* salary DECIMAL(5,2) |
57
|
|
|
* In this example, 5 is the precision and 2 is the scale. |
58
|
|
|
* Standard SQL requires that DECIMAL(5,2) be able to store any value |
59
|
|
|
* with five digits and two decimals, so values that can be stored in |
60
|
|
|
* the salary column range from -999.99 to 999.99. |
61
|
|
|
* |
62
|
|
|
* @return int the $numericPrecision |
63
|
|
|
*/ |
64
|
|
|
public function getNumericPrecision() |
65
|
|
|
{ |
66
|
|
|
return $this->numericPrecision; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param int $numericPrecision the $numericPrevision to set |
71
|
|
|
* @return DecimalColumn |
72
|
|
|
*/ |
73
|
|
|
public function setNumericPrecision($numericPrecision) |
74
|
|
|
{ |
75
|
|
|
$this->numericPrecision = $numericPrecision; |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Return the scale (number of decimal digits) |
81
|
|
|
* salary DECIMAL(5,2) |
82
|
|
|
* In this example, 5 is the precision and 2 is the scale. |
83
|
|
|
* Standard SQL requires that DECIMAL(5,2) be able to store any value |
84
|
|
|
* with five digits and two decimals, so values that can be stored in |
85
|
|
|
* the salary column range from -999.99 to 999.99. |
86
|
|
|
* |
87
|
|
|
* @return integer the $numericScale |
88
|
|
|
*/ |
89
|
|
|
public function getNumericScale() |
90
|
|
|
{ |
91
|
|
|
return $this->numericScale; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param integer $numericScale the $numericScale to set |
96
|
|
|
* @return DecimalColumn |
97
|
|
|
*/ |
98
|
|
|
public function setNumericScale($numericScale) |
99
|
|
|
{ |
100
|
|
|
$this->numericScale = $numericScale; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|