Class Phalcon\Db\Index

implements Phalcon\Db\IndexInterface

Source on GitHub

Allows to define indexes to be used on tables. Indexes are a common way to enhance database performance. An index allows the database server to find and retrieve specific rows much faster than it could do without an index

  1. <?php
  2. // Define new unique index
  3. $index_unique = new \Phalcon\Db\Index(
  4. 'column_UNIQUE',
  5. [
  6. 'column',
  7. 'column'
  8. ],
  9. 'UNIQUE'
  10. );
  11. // Define new primary index
  12. $index_primary = new \Phalcon\Db\Index(
  13. 'PRIMARY',
  14. [
  15. 'column'
  16. ]
  17. );
  18. // Add index to existing table
  19. $connection->addIndex("robots", null, $index_unique);
  20. $connection->addIndex("robots", null, $index_primary);

Methods

public getName ()

Index name

public getColumns ()

Index columns

public getType ()

Index type

public __construct (mixed $name, array $columns, [mixed $type])

Phalcon\Db\Index constructor

public static __set_state (array $data)

Restore a Phalcon\Db\Index object from export