yii\db\pgsql\QueryBuilder::createIndex PHP Method

createIndex() public method

Builds a SQL statement for creating a new index.
See also: http://www.postgresql.org/docs/8.2/static/sql-createindex.html
public createIndex ( string $name, string $table, string | array $columns, boolean | string $unique = false ) : string
$name string the name of the index. The name will be properly quoted by the method.
$table string the table that the new index will be created for. The table name will be properly quoted by the method.
$columns string | array the column(s) that should be included in the index. If there are multiple columns, separate them with commas or use an array to represent them. Each column name will be properly quoted by the method, unless a parenthesis is found in the name.
$unique boolean | string whether to make this a UNIQUE index constraint. You can pass `true` or [[INDEX_UNIQUE]] to create a unique index, `false` to make a non-unique index using the default index type, or one of the following constants to specify the index method to use: [[INDEX_B_TREE]], [[INDEX_HASH]], [[INDEX_GIST]], [[INDEX_GIN]].
return string the SQL statement for creating a new index.
    public function createIndex($name, $table, $columns, $unique = false)
    {
        if ($unique === self::INDEX_UNIQUE || $unique === true) {
            $index = false;
            $unique = true;
        } else {
            $index = $unique;
            $unique = false;
        }
        return ($unique ? 'CREATE UNIQUE INDEX ' : 'CREATE INDEX ') . $this->db->quoteTableName($name) . ' ON ' . $this->db->quoteTableName($table) . ($index !== false ? " USING {$index}" : '') . ' (' . $this->buildColumns($columns) . ')';
    }