lithium\data\source\Database::_buildConstraints()

protected method

Helper for building columns constraints

Parameters

  • array $constraints

    The array of constraints

  • type $schema

    The schema of the table

  • type $joiner

    The join character

Returns

string

The SQL constraints

Source

	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', ['column' => $primary]);
		}
		return $result;
	}