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\Constraint
;
12 class UniqueKey
extends AbstractConstraint
17 protected $specification = 'CONSTRAINT UNIQUE KEY %s(...)';
20 * @param string $column
21 * @param null|string $name
23 public function __construct($column, $name = null)
25 $this->setColumns($column);
32 public function getExpressionData()
34 $colCount = count($this->columns
);
37 $values[] = ($this->name
) ?
$this->name
: '';
39 $newSpecTypes = array(self
::TYPE_IDENTIFIER
);
40 $newSpecParts = array();
42 for ($i = 0; $i < $colCount; $i++
) {
43 $newSpecParts[] = '%s';
44 $newSpecTypes[] = self
::TYPE_IDENTIFIER
;
47 $newSpec = str_replace('...', implode(', ', $newSpecParts), $this->specification
);
51 array_merge($values, $this->columns
),