メインコンテンツまでスキップ
Version: Fegg 5.x

Pdo::createIndex

CREATE INDEXのクエリを組み立てます

説明​

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

Create [UNIQUE] Index "name" ON "table" (columns)を組み立てます。

引数​

名前データ型デフォルト備考
$tablestringテーブル名
$fieldarrayインデックスの定義(下記)

インデックスの定義​

キーデータ型備考
namestringインデックス名
uniquebooleanUNIQUEインデックスにする
targetstringカラム(カンマ区切り)

例​

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();