3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Db\Sql\Ddl\Column
;
12 class Column
implements ColumnInterface
15 * @var null|string|int
17 protected $default = null;
22 protected $isNullable = false;
27 protected $name = null;
32 protected $options = array();
37 protected $specification = '%s %s';
42 protected $type = 'INTEGER';
45 * @param null|string $name
47 public function __construct($name = null)
49 (!$name) ?
: $this->setName($name);
56 public function setName($name)
65 public function getName()
71 * @param bool $nullable
74 public function setNullable($nullable)
76 $this->isNullable
= (bool) $nullable;
83 public function isNullable()
85 return $this->isNullable
;
89 * @param null|string|int $default
92 public function setDefault($default)
94 $this->default = $default;
99 * @return null|string|int
101 public function getDefault()
103 return $this->default;
107 * @param array $options
110 public function setOptions(array $options)
112 $this->options
= $options;
117 * @param string $name
118 * @param string $value
121 public function setOption($name, $value)
123 $this->options
[$name] = $value;
130 public function getOptions()
132 return $this->options
;
138 public function getExpressionData()
140 $spec = $this->specification
;
143 $params[] = $this->name
;
144 $params[] = $this->type
;
146 $types = array(self
::TYPE_IDENTIFIER
, self
::TYPE_LITERAL
);
148 if (!$this->isNullable
) {
149 $params[1] .= ' NOT NULL';
152 if ($this->default !== null) {
153 $spec .= ' DEFAULT %s';
154 $params[] = $this->default;
155 $types[] = self
::TYPE_VALUE
;