src/RocknRoot/StrayFw/Database/Postgres/Mutation/AddUnique.php
public static function statement(Database $database, $modelName, $tableName, array $tableDefinition, $uniqueName)
    {
        $uniqueDefinition = $tableDefinition['uniques'][$uniqueName];
        $fields = array();
        foreach ($uniqueDefinition as $field) {
            if (isset($tableDefinition['fields'][$field]['name']) === true) {
                $fields[] = $tableDefinition['fields'][$field]['name'];
            } else {
                $fields[] = Helper::codifyName($modelName) . '_' . Helper::codifyName($field);
            }
        }
        $statement = $database->getMasterLink()->prepare('ALTER TABLE ' . $tableName . ' ADD CONSTRAINT ' . $uniqueName . ' UNIQUE (' . implode(', ', $fields) . ')');

        return $statement;
    }
public static function statement(Database $database, $modelName, $tableName, array $tableDefinition, $uniqueName)
    {
        $uniqueDefinition = $tableDefinition['uniques'][$uniqueName];
        $fields = array();
        foreach ($uniqueDefinition as $field) {
            if (isset($tableDefinition['fields'][$field]['name']) === true) {
                $fields[] = $tableDefinition['fields'][$field]['name'];
            } else {
                $fields[] = Helper::codifyName($modelName) . '_' . Helper::codifyName($field);
            }
        }
        $statement = $database->getMasterLink()->prepare('ALTER TABLE ' . $tableName . ' ADD CONSTRAINT ' . $uniqueName . ' UNIQUE (' . implode(', ', $fields) . ')');

        return $statement;
    }
public static function statement ( Database $ database , $ modelName , $ tableName , array $ tableDefinition , $ uniqueName ) { $ uniqueDefinition = $ tableDefinition [ 'uniques' ] [ $ uniqueName ] ; $ fields = array ( ) ; foreach ( $ uniqueDefinition as $ field ) { if ( isset ( $ tableDefinition [ 'fields' ] [ $ field ] [ 'name' ] ) === true ) { $ fields [ ] = $ tableDefinition [ 'fields' ] [ $ field ] [ 'name' ] ; } else { $ fields [ ] = Helper :: codifyName ( $ modelName ) . '_' . Helper :: codifyName ( $ field ) ; } } $ statement = $ database -> getMasterLink ( ) -> prepare ( 'ALTER TABLE ' . $ tableName . ' ADD CONSTRAINT ' . $ uniqueName . ' UNIQUE (' . implode ( ', ' , $ fields ) . ')' ) ; return $ statement ; }
Prepare and return according PDO statement.

@param  Database     $database         database
@param  string       $modelName        model name
@param  string       $tableName        table real name
@param  array        $tableDefinition  table definition
@param  string       $uniqueName       unique constraint name
@return \PDOStatement $statement prepared query
Prepare and return according PDO statement .