<?php
header("content-type:text/html; charset=utf-8");
/**
* 批量删除mongo collections
*/
//http://php.net/manual/zh/mongodb.getcollectionnames.php
//http://www.php.net/manual/en/mongodb.dropcollection.php
$MongoHost = "mongodb://************";
$connection = new Mongo($MongoHost);
$connections = $connection->selectDB("collections");
$CollectionNames = $connections->getCollectionNames();
foreach ($CollectionNames as $Names) {
$coupon_receive_1 = "xxx_1"; //需要删除的名称前缀
$coupon_receive_2 = "xxx_2";
$name = substr($Names , 0, 16); //截取字符串做匹配
if($name == $coupon_receive_2 || $name == $coupon_receive_1 ){
echo $Names . "<br>";
echo ++$i;
$a = $connections->dropCollection($Names);
usleep(100);
}
}
header("content-type:text/html; charset=utf-8");
/**
* 批量删除mongo collections
*/
//http://php.net/manual/zh/mongodb.getcollectionnames.php
//http://www.php.net/manual/en/mongodb.dropcollection.php
$MongoHost = "mongodb://************";
$connection = new Mongo($MongoHost);
$connections = $connection->selectDB("collections");
$CollectionNames = $connections->getCollectionNames();
foreach ($CollectionNames as $Names) {
$coupon_receive_1 = "xxx_1"; //需要删除的名称前缀
$coupon_receive_2 = "xxx_2";
$name = substr($Names , 0, 16); //截取字符串做匹配
if($name == $coupon_receive_2 || $name == $coupon_receive_1 ){
echo $Names . "<br>";
echo ++$i;
$a = $connections->dropCollection($Names);
usleep(100);
}
}