lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
protected function getTableConstraintDeclarationSQL(Constraint $constraint, $name = null)
    {
        if ($constraint instanceof ForeignKeyConstraint) {
            return $this->getForeignKeyDeclarationSQL($constraint);
        }

        if (! $constraint instanceof Index) {
            throw new InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
        }

        if (! $constraint->isPrimary() && ! $constraint->isUnique()) {
            throw new InvalidArgumentException(
                'Can only create primary, unique or foreign key constraint declarations, no common index declarations ' .
                'with getTableConstraintDeclarationSQL().'
            );
        }

        $constraintColumns = $constraint->getQuotedColumns($this);

        if (empty($constraintColumns)) {
            throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
        }

        $sql   = '';
        $flags = '';

        if (! empty($name)) {
            $name = new Identifier($name);
            $sql .= 'CONSTRAINT ' . $name->getQuotedName($this) . ' ';
        }

        if ($constraint->hasFlag('clustered')) {
            $flags = 'CLUSTERED ';
        }

        if ($constraint->isPrimary()) {
            return $sql . 'PRIMARY KEY ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
        }

        return $sql . 'UNIQUE ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
    }
protected function getTableConstraintDeclarationSQL(Constraint $constraint, $name = null)
    {
        if ($constraint instanceof ForeignKeyConstraint) {
            return $this->getForeignKeyDeclarationSQL($constraint);
        }

        if (! $constraint instanceof Index) {
            throw new InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
        }

        if (! $constraint->isPrimary() && ! $constraint->isUnique()) {
            throw new InvalidArgumentException(
                'Can only create primary, unique or foreign key constraint declarations, no common index declarations ' .
                'with getTableConstraintDeclarationSQL().'
            );
        }

        $constraintColumns = $constraint->getQuotedColumns($this);

        if (empty($constraintColumns)) {
            throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
        }

        $sql   = '';
        $flags = '';

        if (! empty($name)) {
            $name = new Identifier($name);
            $sql .= 'CONSTRAINT ' . $name->getQuotedName($this) . ' ';
        }

        if ($constraint->hasFlag('clustered')) {
            $flags = 'CLUSTERED ';
        }

        if ($constraint->isPrimary()) {
            return $sql . 'PRIMARY KEY ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
        }

        return $sql . 'UNIQUE ' . $flags . '(' . $this->getIndexFieldDeclarationListSQL($constraintColumns) . ')';
    }
protected function getTableConstraintDeclarationSQL ( Constraint $ constraint , $ name = null ) { if ( $ constraint instanceof ForeignKeyConstraint ) { return $ this -> getForeignKeyDeclarationSQL ( $ constraint ) ; } if ( ! $ constraint instanceof Index ) { throw new InvalidArgumentException ( 'Unsupported constraint type: ' . get_class ( $ constraint ) ) ; } if ( ! $ constraint -> isPrimary ( ) && ! $ constraint -> isUnique ( ) ) { throw new InvalidArgumentException ( 'Can only create primary, unique or foreign key constraint declarations, no common index declarations ' . 'with getTableConstraintDeclarationSQL().' ) ; } $ constraintColumns = $ constraint -> getQuotedColumns ( $ this ) ; if ( empty ( $ constraintColumns ) ) { throw new InvalidArgumentException ( "Incomplete definition. 'columns' required." ) ; } $ sql = '' ; $ flags = '' ; if ( ! empty ( $ name ) ) { $ name = new Identifier ( $ name ) ; $ sql .= 'CONSTRAINT ' . $ name -> getQuotedName ( $ this ) . ' ' ; } if ( $ constraint -> hasFlag ( 'clustered' ) ) { $ flags = 'CLUSTERED ' ; } if ( $ constraint -> isPrimary ( ) ) { return $ sql . 'PRIMARY KEY ' . $ flags . '(' . $ this -> getIndexFieldDeclarationListSQL ( $ constraintColumns ) . ')' ; } return $ sql . 'UNIQUE ' . $ flags . '(' . $ this -> getIndexFieldDeclarationListSQL ( $ constraintColumns ) . ')' ; }
Returns the SQL snippet for creating a table constraint.

@param Constraint  $constraint The table constraint to create the SQL snippet for.
@param string|null $name       The table constraint name to use if any.

@return string

@throws InvalidArgumentException If the given table constraint type is not supported by this method.
Returns the SQL snippet for creating a table constraint .