Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
floatfield.php
1
<?php
9
namespace
Bitrix\Main\ORM\Fields
;
10
11
use
Bitrix\Main\DB\SqlExpression
;
12
19
class
FloatField
extends
ScalarField
20
{
22
protected
$precision
;
23
25
protected
$scale
;
26
35
public
function
__construct
(
$name
, $parameters = array())
36
{
37
parent::__construct(
$name
, $parameters);
38
39
if
(isset($parameters[
'scale'
]))
40
{
41
$this->scale = intval($parameters[
'scale'
]);
42
}
43
44
if
(isset($parameters[
'precision'
]))
45
{
46
$this->precision = intval($parameters[
'precision'
]);
47
}
48
}
49
55
public
function
configurePrecision
(
$precision
)
56
{
57
$this->precision = (int)
$precision
;
58
return
$this;
59
}
60
66
public
function
configureScale
(
$scale
)
67
{
68
$this->scale = (int)
$scale
;
69
return
$this;
70
}
71
75
public
function
getPrecision
()
76
{
77
return
$this->precision
;
78
}
79
83
public
function
getScale
()
84
{
85
return
$this->scale
;
86
}
87
93
public
function
cast
($value)
94
{
95
if
($this->is_nullable && $value ===
null
)
96
{
97
return
$value;
98
}
99
100
if
($value instanceof
SqlExpression
)
101
{
102
return
$value;
103
}
104
105
$value = doubleval($value);
106
107
if
($this->scale !==
null
)
108
{
109
$value = round($value, $this->scale);
110
}
111
112
return
$value;
113
}
114
121
public
function
convertValueFromDb
($value)
122
{
123
return
$this->
getConnection
()->getSqlHelper()->convertFromDbFloat($value);
124
}
125
132
public
function
convertValueToDb
($value)
133
{
134
if
($value instanceof
SqlExpression
)
135
{
136
return
$value;
137
}
138
139
return
$value ===
null
&& $this->is_nullable
140
? $value
141
: $this->
getConnection
()->getSqlHelper()->convertToDbFloat($value);
142
}
143
147
public
function
getGetterTypeHint
()
148
{
149
return
$this->
getNullableTypeHint
(
'\\float'
);
150
}
151
155
public
function
getSetterTypeHint
()
156
{
157
return
$this->
getNullableTypeHint
(
'\\float'
);
158
}
159
}
Bitrix\Main\DB\SqlExpression
Definition
sqlexpression.php:19
Bitrix\Main\ORM\Fields\Field\$name
$name
Definition
field.php:27
Bitrix\Main\ORM\Fields\Field\getConnection
getConnection()
Definition
field.php:626
Bitrix\Main\ORM\Fields\FloatField
Definition
floatfield.php:20
Bitrix\Main\ORM\Fields\FloatField\getPrecision
getPrecision()
Definition
floatfield.php:75
Bitrix\Main\ORM\Fields\FloatField\getScale
getScale()
Definition
floatfield.php:83
Bitrix\Main\ORM\Fields\FloatField\getSetterTypeHint
getSetterTypeHint()
Definition
floatfield.php:155
Bitrix\Main\ORM\Fields\FloatField\cast
cast($value)
Definition
floatfield.php:93
Bitrix\Main\ORM\Fields\FloatField\configureScale
configureScale($scale)
Definition
floatfield.php:66
Bitrix\Main\ORM\Fields\FloatField\configurePrecision
configurePrecision($precision)
Definition
floatfield.php:55
Bitrix\Main\ORM\Fields\FloatField\__construct
__construct($name, $parameters=array())
Definition
floatfield.php:35
Bitrix\Main\ORM\Fields\FloatField\$scale
$scale
Definition
floatfield.php:25
Bitrix\Main\ORM\Fields\FloatField\getGetterTypeHint
getGetterTypeHint()
Definition
floatfield.php:147
Bitrix\Main\ORM\Fields\FloatField\convertValueFromDb
convertValueFromDb($value)
Definition
floatfield.php:121
Bitrix\Main\ORM\Fields\FloatField\$precision
$precision
Definition
floatfield.php:22
Bitrix\Main\ORM\Fields\FloatField\convertValueToDb
convertValueToDb($value)
Definition
floatfield.php:132
Bitrix\Main\ORM\Fields\ScalarField
Definition
scalarfield.php:19
Bitrix\Main\ORM\Fields\ScalarField\getNullableTypeHint
getNullableTypeHint(string $type)
Definition
scalarfield.php:255
Bitrix\Main\ORM\Fields
Definition
arrayfield.php:9
modules
main
lib
orm
fields
floatfield.php
Создано системой
1.10.0