1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
floatfield.php
См. документацию.
1<?php
8
9namespace Bitrix\Main\ORM\Fields;
10
11use Bitrix\Main\DB\SqlExpression;
12
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
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}
getConnection()
Определения field.php:638
configureScale($scale)
Определения floatfield.php:66
configurePrecision($precision)
Определения floatfield.php:55
__construct($name, $parameters=array())
Определения floatfield.php:35
convertValueFromDb($value)
Определения floatfield.php:121
convertValueToDb($value)
Определения floatfield.php:132
getNullableTypeHint(string $type)
Определения scalarfield.php:301
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804