note 113396 added to mongocollection.deleteindex
| From: | nanhe dot kumar at gmail dot com | Date: | Sun, 06 Oct 2013 01:23:50 +0000 |
| Subject: | note 113396 added to mongocollection.deleteindex | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196476@lists.php.net to get a copy of this message | ||
<?php
/*
How can delete Index through Index name.
*/
function deleteIndex($db, $collection, $indexName) {
if (class_exists("MongoClient")) {
$m = new MongoClient();
} else {
$m = new Mongo();
}
$indexes = $m->{$db}->{$collection}->getIndexInfo();
foreach ($indexes as $index) {
if ($index['name'] === $indexName) {
return $m->{$db}->command(array("deleteIndexes" =>
$this->m->{$db}->{$collection}->getName(), "index"
=>$index['key']));
break;
}
}
return false;
}
$response=deleteIndex('student','class','roll');
echo "<pre>;
print_r($response);
echo "</pre>";
?>
Array
(
[nIndexesWas] => 2
[ok] => 1
)
----
Server IP: 69.147.83.199
Probable Submitter: 14.98.48.255
----
Manual Page -- http://php.net/manual/en/mongocollection.deleteindex.php
Edit -- https://master.php.net/note/edit/113396
Del: integrated -- https://master.php.net/note/delete/113396/integrated
Del: useless -- https://master.php.net/note/delete/113396/useless
Del: bad code -- https://master.php.net/note/delete/113396/bad+code
Del: spam -- https://master.php.net/note/delete/113396/spam
Del: non-english -- https://master.php.net/note/delete/113396/non-english
Del: in docs -- https://master.php.net/note/delete/113396/in+docs
Del: other reasons-- https://master.php.net/note/delete/113396
Reject -- https://master.php.net/note/reject/113396
Search -- https://master.php.net/manage/user-notes.php