(沒有版本資訊,可能只存在於 Git 中)
Collection::dropIndex — 刪除集合索引
index_name
要刪除的集合索引名稱。
範例 #1 mysql_xdevapi\Collection::dropIndex() 範例
<?php
$session = mysql_xdevapi\getSession("mysqlx://user:password@localhost");
$session->sql("DROP DATABASE IF EXISTS addressbook")->execute();
$session->sql("CREATE DATABASE addressbook")->execute();
$schema = $session->getSchema("addressbook");
$create = $schema->createCollection("people");
// ...
$collection = $schema->getCollection("people");
$collection->createIndex(
'myindex',
'{"fields": [{"field": "$.name", "type": "TEXT(25)", "required": true}], "unique": false}'
);
// ...
if ($collection->dropIndex('myindex')) {
echo "找到名為 'myindex' 的索引,已刪除。";
}
?>
以上範例會輸出
An index named 'myindex' was found, and dropped.