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 UniqueKey

UniqueKey class

Models a unique key constraint, and provides methods to set driver specific attributes.

Namespace: Cake\Database\Schema

Constants

  • string
    CHECK ¶
    TableSchema::CONSTRAINT_CHECK
  • string
    FOREIGN ¶
    TableSchema::CONSTRAINT_FOREIGN
  • string
    PRIMARY ¶
    TableSchema::CONSTRAINT_PRIMARY
  • string
    UNIQUE ¶
    TableSchema::CONSTRAINT_UNIQUE

Method Summary

  • __construct() public

    Constructor

  • getColumns() public

    Gets the constraint columns.

  • getLength() public

    Gets the constraint length.

  • getName() public

    Gets the constraint name.

  • getType() public

    Gets the constraint type.

  • setColumns() public

    Sets the constraint columns.

  • setLength() public

    Sets the constraint length.

  • setName() public

    Sets the constraint name.

  • setType() public

    Sets the constraint type.

  • toArray() public

    Converts a constraint to an array that is compatible with the constructor.

Method Detail

__construct() ¶ public

__construct(string $name, array<string> $columns, array<string, int>|null $length = null)

Constructor

Parameters
string $name

The name of the constraint.

array<string> $columns

The columns to constraint.

array<string, int>|null $length optional

The length of the columns, if applicable.

getColumns() ¶ public

getColumns(): ?array<string>

Gets the constraint columns.

Returns
?array<string>

getLength() ¶ public

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

Gets the constraint length.

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

Returns
array<string, int>|null

getName() ¶ public

getName(): ?string

Gets the constraint name.

Returns
?string

getType() ¶ public

getType(): string

Gets the constraint type.

Returns
string

setColumns() ¶ public

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

Sets the constraint columns.

Parameters
array<string>|string $columns

Columns

Returns
$this

setLength() ¶ public

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

Sets the constraint length.

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

Parameters
array<string, int> $length

array of length values

Returns
$this

setName() ¶ public

setName(string $name): $this

Sets the constraint name.

Parameters
string $name

Name

Returns
$this

setType() ¶ public

setType(string $type): $this

Sets the constraint type.

Parameters
string $type

Type

Returns
$this

toArray() ¶ public

toArray(): array<string, mixed>

Converts a constraint to an array that is compatible with the 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