CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.3 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.3
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Query
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class Index

Index value object

Models a database index and its attributes.

Namespace: Cake\Database\Schema

Constants

  • string
    FULLTEXT ¶
    'fulltext'
  • string
    INDEX ¶
    'index'

Method Summary

  • __construct() public

    Constructor

  • getColumns() public

    Gets the index columns.

  • getInclude() public

    Gets the index included columns.

  • getLength() public

    Gets the index length.

  • getName() public

    Gets the index name.

  • getOrder() public

    Gets the index columns sort order.

  • getType() public

    Gets the index type.

  • getWhere() public

    Get the where clause for partial indexes.

  • setAttributes() public

    Utility method that maps an array of index options to this object's methods.

  • setColumns() public

    Sets the index columns.

  • setInclude() public

    Sets the index included columns for a 'covering index'.

  • setLength() public

    Sets the index length.

  • setName() public

    Sets the index name.

  • setOrder() public

    Sets the index columns sort order.

  • setType() public

    Sets the index type.

  • setWhere() public

    Set the where clause for partial indexes.

  • toArray() public

    Convert an index into an array that is compatible with the Index constructor.

Method Detail

__construct() ¶ public

__construct(string $name, array<string> $columns, string $type = self::INDEX, array<string, int>|int|null $length = null, array<string>|null $order = null, array<string>|null $include = null, ?string $where = null)

Constructor

Parameters
string $name

The name of the index.

array<string> $columns

The columns to index.

string $type optional

The type of index, e.g. 'index', 'fulltext'.

array<string, int>|int|null $length optional

The length of the index.

array<string>|null $order optional

The sort order of the index columns.

array<string>|null $include optional

The included columns for covering indexes.

?string $where optional

The where clause for partial indexes.

getColumns() ¶ public

getColumns(): ?array<string>

Gets the index columns.

Returns
?array<string>

getInclude() ¶ public

getInclude(): ?array<string>

Gets the index included columns.

Returns
?array<string>

getLength() ¶ public

getLength(): array<string, int>|int|null

Gets the index length.

Can be an array of column names and lengths under MySQL.

Returns
array<string, int>|int|null

getName() ¶ public

getName(): ?string

Gets the index name.

Returns
?string

getOrder() ¶ public

getOrder(): ?array<string>

Gets the index columns sort order.

Returns
?array<string>

getType() ¶ public

getType(): string

Gets the index type.

Returns
string

getWhere() ¶ public

getWhere(): ?string

Get the where clause for partial indexes.

Returns
?string

setAttributes() ¶ public

setAttributes(array<string, mixed> $attributes): $this

Utility method that maps an array of index options to this object's methods.

Parameters
array<string, mixed> $attributes

Attributes to set.

Returns
$this
Throws
RuntimeException

setColumns() ¶ public

setColumns(array<string>|string $columns): $this

Sets the index columns.

Parameters
array<string>|string $columns

Columns

Returns
$this

setInclude() ¶ public

setInclude(array<string> $includedColumns): $this

Sets the index included columns for a 'covering index'.

In postgres and sqlserver, indexes can define additional non-key columns to build 'covering indexes'. This feature allows you to further optimize well-crafted queries that leverage specific indexes by reading all data from the index.

Parameters
array<string> $includedColumns

Columns

Returns
$this

setLength() ¶ public

setLength(array<string, int>|int $length): $this

Sets the index length.

In MySQL indexes can have limit clauses to control the number of characters indexed in text and char columns.

Parameters
array<string, int>|int $length

length value or array of length value

Returns
$this

setName() ¶ public

setName(string $name): $this

Sets the index name.

Parameters
string $name

Name

Returns
$this

setOrder() ¶ public

setOrder(array<string> $order): $this

Sets the index columns sort order.

Parameters
array<string> $order

column name sort order key value pair

Returns
$this

setType() ¶ public

setType(string $type): $this

Sets the index type.

Parameters
string $type

Type

Returns
$this

setWhere() ¶ public

setWhere(?string $where): $this

Set the where clause for partial indexes.

Parameters
?string $where

The where clause for partial indexes.

Returns
$this

toArray() ¶ public

toArray(): array<string, mixed>

Convert an index into an array that is compatible with the Index constructor.

Returns
array<string, mixed>
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs