メインコンテンツまでスキップ
Version: Fegg 5.x(開発版)

Pdo::createIndex

Set create index query

Description​

public self Pdo::createIndex( string $table, array $field )

Builds Create [UNIQUE] Index "name" ON "table" (columns).

Arguments​

NameData typeDefaultRemarks
$tablestringTable name
$fieldarrayIndex definition (below)

Index definition​

KeyData typeRemarks
namestringIndex name
uniquebooleanCreate a UNIQUE index
targetstringColumns, separated by commas

Example​

Controller
$db = new \Fegg\Database\Pdo();

// Create UNIQUE Index "sample_title" ON "sample" (title)
$db->createIndex('sample', array('name' => 'sample_title', 'unique' => true, 'target' => 'title'))->execute();