public function createIndex($table, $name, $unique = false, $cols = null)
{
// are there any columns for the index?
if (empty($cols)) {
// take the column name from the index name
$cols = $name;
}
// check the table and index names
$this->_checkIdentifier('table', $table);
$this->_checkIdentifier('index', $name);
// modify the index name as-needed
$name = $this->_modIndexName($table, $name);
// quote identifiers
$name = $this->quoteName($name);
$table = $this->quoteName($table);
$cols = $this->quoteName($cols);
// create a string of column names
$cols = implode(', ', (array) $cols);
// create index entry statement
if ($unique) {
$stmt = "CREATE UNIQUE INDEX {$name} ON {$table} ({$cols})";
} else {
$stmt = "CREATE INDEX {$name} ON {$table} ({$cols})";
}
return $this->query($stmt);
}