Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
integerfield.php
1<?php
10
12
20{
22 protected $size = 4;
23
32 function __construct($name, $parameters = array())
33 {
34 parent::__construct($name, $parameters);
35
36 if(isset($parameters['size']) && intval($parameters['size']) > 0)
37 {
38 $this->size = intval($parameters['size']);
39 }
40 }
41
47 public function configureSize($size)
48 {
49 $this->size = (int)$size;
50 return $this;
51 }
52
57 public function getSize()
58 {
59 return $this->size;
60 }
61
67 public function cast($value)
68 {
69 if ($this->is_nullable && $value === null)
70 {
71 return $value;
72 }
73
74 if ($value instanceof SqlExpression)
75 {
76 return $value;
77 }
78
79 return (int) $value;
80 }
81
88 public function convertValueFromDb($value)
89 {
90 return $this->getConnection()->getSqlHelper()->convertFromDbInteger($value);
91 }
92
99 public function convertValueToDb($value)
100 {
101 if ($value instanceof SqlExpression)
102 {
103 return $value;
104 }
105
106 return $value === null && $this->is_nullable
107 ? $value
108 : $this->getConnection()->getSqlHelper()->convertToDbInteger($value);
109 }
110
114 public function getGetterTypeHint()
115 {
116 return $this->getNullableTypeHint('\\int');
117 }
118
122 public function getSetterTypeHint()
123 {
124 return $this->getNullableTypeHint('\\int');
125 }
126}
__construct($name, $parameters=array())