Pdo::createIndex
CREATE INDEXのクエリを組み立てます
説明
public self Pdo::createIndex( string $table, array $field )
Create [UNIQUE] Index "name" ON "table" (columns)を組み立てます。
引数
| 名前 | データ型 | デフォルト | 備考 |
|---|---|---|---|
| $table | string | テーブル名 | |
| $field | array | インデックスの定義(下記) |
インデックスの定義
| キー | データ型 | 備考 |
|---|---|---|
name | string | インデックス名 |
unique | boolean | UNIQUEインデックスにする |
target | string | カラム(カンマ区切り) |
例
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();