Source of file Column.php
Size: 3,013 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Db/Sql/Ddl/Column/Column.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Db\Sql\Ddl\Column; class Column implements ColumnInterface { /** * @var null|string|int */ protected $default = null; /** * @var bool */ protected $isNullable = false; /** * @var string */ protected $name = null; /** * @var array */ protected $options = array(); /** * @var string */ protected $specification = '%s %s'; /** * @var string */ protected $type = 'INTEGER'; /** * @param null|string $name */ public function __construct($name = null) { (!$name) ?: $this->setName($name); } /** * @param string $name * @return self */ public function setName($name) { $this->name = $name; return $this; } /** * @return null|string */ public function getName() { return $this->name; } /** * @param bool $nullable * @return self */ public function setNullable($nullable) { $this->isNullable = (bool) $nullable; return $this; } /** * @return bool */ public function isNullable() { return $this->isNullable; } /** * @param null|string|int $default * @return self */ public function setDefault($default) { $this->default = $default; return $this; } /** * @return null|string|int */ public function getDefault() { return $this->default; } /** * @param array $options * @return self */ public function setOptions(array $options) { $this->options = $options; return $this; } /** * @param string $name * @param string $value * @return self */ public function setOption($name, $value) { $this->options[$name] = $value; return $this; } /** * @return array */ public function getOptions() { return $this->options; } /** * @return array */ public function getExpressionData() { $spec = $this->specification; $params = array(); $params[] = $this->name; $params[] = $this->type; $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL); if (!$this->isNullable) { $params[1] .= ' NOT NULL'; } if ($this->default !== null) { $spec .= ' DEFAULT %s'; $params[] = $this->default; $types[] = self::TYPE_VALUE; } return array(array( $spec, $params, $types, )); } } |