MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
Column.php
Ir para a documentação deste ficheiro.
1<?php
2/*
3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the LGPL. For more information, see
17 * <http://www.doctrine-project.org>.
18 */
19
20namespace Doctrine\DBAL\Schema;
21
22use \Doctrine\DBAL\Types\Type;
24
34class Column extends AbstractAsset
35{
39 protected $_type;
40
44 protected $_length = null;
45
49 protected $_precision = 10;
50
54 protected $_scale = 0;
55
59 protected $_unsigned = false;
60
64 protected $_fixed = false;
65
69 protected $_notnull = true;
70
74 protected $_default = null;
75
79 protected $_autoincrement = false;
80
84 protected $_platformOptions = array();
85
89 protected $_columnDefinition = null;
90
105 public function __construct($columnName, Type $type, array $options=array())
106 {
107 $this->_setName($columnName);
108 $this->setType($type);
109 $this->setOptions($options);
110 }
111
116 public function setOptions(array $options)
117 {
118 foreach ($options AS $name => $value) {
119 $method = "set".$name;
120 if (method_exists($this, $method)) {
121 $this->$method($value);
122 }
123 }
124 return $this;
125 }
126
131 public function setType(Type $type)
132 {
133 $this->_type = $type;
134 return $this;
135 }
136
141 public function setLength($length)
142 {
143 if($length !== null) {
144 $this->_length = (int)$length;
145 } else {
146 $this->_length = null;
147 }
148 return $this;
149 }
150
155 public function setPrecision($precision)
156 {
157 $this->_precision = (int)$precision;
158 return $this;
159 }
160
165 public function setScale($scale)
166 {
167 $this->_scale = $scale;
168 return $this;
169 }
170
176 public function setUnsigned($unsigned)
177 {
178 $this->_unsigned = (bool)$unsigned;
179 return $this;
180 }
181
187 public function setFixed($fixed)
188 {
189 $this->_fixed = (bool)$fixed;
190 return $this;
191 }
192
197 public function setNotnull($notnull)
198 {
199 $this->_notnull = (bool)$notnull;
200 return $this;
201 }
202
208 public function setDefault($default)
209 {
210 $this->_default = $default;
211 return $this;
212 }
213
219 public function setPlatformOptions(array $platformOptions)
220 {
221 $this->_platformOptions = $platformOptions;
222 return $this;
223 }
224
231 public function setPlatformOption($name, $value)
232 {
233 $this->_platformOptions[$name] = $value;
234 return $this;
235 }
236
242 public function setColumnDefinition($value)
243 {
244 $this->_columnDefinition = $value;
245 return $this;
246 }
247
248 public function getType()
249 {
250 return $this->_type;
251 }
252
253 public function getLength()
254 {
255 return $this->_length;
256 }
257
258 public function getPrecision()
259 {
260 return $this->_precision;
261 }
262
263 public function getScale()
264 {
265 return $this->_scale;
266 }
267
268 public function getUnsigned()
269 {
270 return $this->_unsigned;
271 }
272
273 public function getFixed()
274 {
275 return $this->_fixed;
276 }
277
278 public function getNotnull()
279 {
280 return $this->_notnull;
281 }
282
283 public function getDefault()
284 {
285 return $this->_default;
286 }
287
288 public function getPlatformOptions()
289 {
291 }
292
293 public function hasPlatformOption($name)
294 {
295 return isset($this->_platformOptions[$name]);
296 }
297
298 public function getPlatformOption($name)
299 {
300 return $this->_platformOptions[$name];
301 }
302
303 public function getColumnDefinition()
304 {
306 }
307
308 public function getAutoincrement()
309 {
311 }
312
313 public function setAutoincrement($flag)
314 {
315 $this->_autoincrement = $flag;
316 return $this;
317 }
318
322 public function visit(\Doctrine\DBAL\Schema\Visitor $visitor)
323 {
324 $visitor->accept($this);
325 }
326
330 public function toArray()
331 {
332 return array_merge(array(
333 'name' => $this->_name,
334 'type' => $this->_type,
335 'default' => $this->_default,
336 'notnull' => $this->_notnull,
337 'length' => $this->_length,
338 'precision' => $this->_precision,
339 'scale' => $this->_scale,
340 'fixed' => $this->_fixed,
341 'unsigned' => $this->_unsigned,
342 'autoincrement' => $this->_autoincrement,
343 'columnDefinition' => $this->_columnDefinition,
344 ), $this->_platformOptions);
345 }
346}
__construct($columnName, Type $type, array $options=array())
Definição Column.php:105
setPlatformOptions(array $platformOptions)
Definição Column.php:219
setOptions(array $options)
Definição Column.php:116
visit(\Doctrine\DBAL\Schema\Visitor $visitor)
Definição Column.php:322
setPlatformOption($name, $value)
Definição Column.php:231
setPrecision($precision)
Definição Column.php:155