Index
in package
An Index allows your application to define a series of fields that the DBMS should index in order to improve performance of data retrieval.
Please note that indexes on the logical level are "suggestions" that allow the DBMS to improve performance, but these are not required to be followed.
Table of Contents
- $fields : Collection
- The fields that the index contains. Please note that many DBMS (basically all of them) are sensitive to the order in which the fields are provided to the index and they will therefore perform better (or worse) when used properly.
- $name : string
- The name to be given to this index. This will be then suggested to the DBMS. This does not guarantee to be the name the system will end up choosing.
- $primary : bool
- Indicates whether this key is a primary key. Every table can only have one primary key and it is required to have one to create relations between the tables.
- $unique : bool
- Indicates whether this index is unique. Please note that spitfire will override this setting to bool(true) if the index is also primary.
- __construct() : mixed
- Creates a new index for the schema.
- contains() : bool
- Indicates whether a field is contained in this index. This allows an app to check whether it needs to remove an index when a field is removed.
- getFields() : Collection
- Return the field collection
- getName() : string
- Returns the name of the index (if given) and generates a standard name for the index when there is none. The format for these is
- isPrimary() : mixed
- isUnique() : mixed
- putField() : mixed
- setFields() : mixed
- setName() : mixed
- setPrimary() : mixed
- unique() : mixed
Properties
$fields
The fields that the index contains. Please note that many DBMS (basically all of them) are sensitive to the order in which the fields are provided to the index and they will therefore perform better (or worse) when used properly.
private
Collection
$fields
$name
The name to be given to this index. This will be then suggested to the DBMS. This does not guarantee to be the name the system will end up choosing.
private
string
$name
$primary
Indicates whether this key is a primary key. Every table can only have one primary key and it is required to have one to create relations between the tables.
private
bool
$primary
= false
$unique
Indicates whether this index is unique. Please note that spitfire will override this setting to bool(true) if the index is also primary.
private
bool
$unique
= false
Methods
__construct()
Creates a new index for the schema.
public
__construct([Collection<string|int, Field> $fields = null ]) : mixed
Parameters
- $fields : Collection<string|int, Field> = null
Return values
mixed —contains()
Indicates whether a field is contained in this index. This allows an app to check whether it needs to remove an index when a field is removed.
public
contains(Field $f) : bool
Parameters
- $f : Field
Return values
bool —getFields()
Return the field collection
public
getFields() : Collection
Return values
Collection —containing the Field
s in this index
getName()
Returns the name of the index (if given) and generates a standard name for the index when there is none. The format for these is
public
getName() : string
idx_tablename_field1_field2
Return values
string —isPrimary()
public
isPrimary() : mixed
Return values
mixed —isUnique()
public
isUnique() : mixed
Return values
mixed —putField()
public
putField(Field $field) : mixed
Parameters
- $field : Field
Return values
mixed —setFields()
public
setFields(mixed $fields) : mixed
Parameters
- $fields : mixed
Return values
mixed —setName()
public
setName(mixed $name) : mixed
Parameters
- $name : mixed
Return values
mixed —setPrimary()
public
setPrimary(mixed $isPrimary) : mixed
Parameters
- $isPrimary : mixed
Return values
mixed —unique()
public
unique([mixed $unique = true ]) : mixed
Parameters
- $unique : mixed = true