(无版本信息可用,可能仅存在于 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.