Index
Less than 1 minute
Index
Trait providing index management methods for SQL-based DBI drivers.
trait IndexIncludes default implementations for listing, creating, dropping, and checking indexes.
Methods
listIndexes
Retrieves a list of indexes for a given table or all tables in the specified schema.
public listIndexes(?string $tableName): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$tableName | string | The name of the table. If null, all tables in the schema will be considered. |
indexExists
Check if an index exists by name for a given table.
public indexExists(string $indexName, ?string $tableName): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$indexName | string | the name of the index to check |
$tableName | string | the name of the table (optional) |
createIndex
Attempt to create an index on a table.
public createIndex(string $indexName, string $tableName, array $idxInfo): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$indexName | string | the name of the index to create |
$tableName | string | the name of the table |
$idxInfo | array | Index definition (columns, uniqueness, type, etc.). A where key makes it a partial index, appending WHERE <where> to restrict the index to matching rows instead of the whole table. |
dropIndex
Attempt to drop an index by name.
public dropIndex(string $indexName, bool $ifExists): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$indexName | string | the name of the index to drop |
$ifExists | bool | if true, do not error if the index does not exist |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000