lithium\data\source\Database::_buildConstraints PHP Method

_buildConstraints() protected method

Helper for building columns constraints
See also: lithium\data\soure\Database::createSchema()
protected _buildConstraints ( array $constraints, type $schema = null, type $joiner = ' ', $primary = false ) : string
$constraints array The array of constraints
$schema type The schema of the table
$joiner type The join character
return string The SQL constraints
    protected function _buildConstraints(array $constraints, $schema = null, $joiner = ' ', $primary = false)
    {
        $result = '';
        foreach ($constraints as $constraint) {
            if (isset($constraint['type'])) {
                $name = $constraint['type'];
                if ($meta = $this->_constraint($name, $constraint, $schema)) {
                    $result .= $joiner . $meta;
                }
                if ($name === 'primary') {
                    $primary = false;
                }
            }
        }
        if ($primary) {
            $result .= $joiner . $this->_constraint('primary', array('column' => $primary));
        }
        return $result;
    }