本文整理汇总了PHP中MongoCollection::deleteIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCollection::deleteIndex方法的具体用法?PHP MongoCollection::deleteIndex怎么用?PHP MongoCollection::deleteIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection::deleteIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dropIndex
/**
* Indicate that the given index should be dropped.
*
* @param string|array $columns
* @return Blueprint
*/
public function dropIndex($columns = null)
{
$columns = $this->fluent($columns);
// Columns are passed as a default array.
if (is_array($columns) && is_int(key($columns))) {
// Transform the columns to the required array format.
$transform = array();
foreach ($columns as $column) {
$transform[$column] = 1;
}
$columns = $transform;
}
$this->collection->deleteIndex($columns);
return $this;
}
示例2: testDeleteIndex
public function testDeleteIndex() {
$idx = $this->object->db->selectCollection('system.indexes');
$this->object->ensureIndex('foo');
$this->object->ensureIndex(array('foo' => -1));
$cursor = $idx->find(array('ns' => 'phpunit.c'));
$num = iterator_count($cursor);
$this->assertEquals(3, $num);
$this->object->deleteIndex(null);
$num = iterator_count($idx->find(array('ns' => 'phpunit.c')));
$this->assertEquals(3, $num);
$this->object->deleteIndex(array('foo' => 1));
$num = iterator_count($idx->find(array('ns' => 'phpunit.c')));
$this->assertEquals(2, $num);
$this->object->deleteIndex('foo');
$num = iterator_count($idx->find(array('ns' => 'phpunit.c')));
$this->assertEquals(2, $num);
$this->object->deleteIndex(array('foo' => -1));
$num = iterator_count($idx->find(array('ns' => 'phpunit.c')));
$this->assertEquals(1, $num);
}
示例3: deleteIndex
/**
* deleteIndex.
*/
public function deleteIndex($keys)
{
$this->time->start();
$return = parent::deleteIndex($keys);
$time = $this->time->stop();
$this->log(array('type' => 'deleteIndex', 'keys' => $keys, 'time' => $time));
return $return;
}
示例4: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$db = \DB::getMongoDB();
$statementsCollection = new MongoCollection($db, 'statements');
$statementsCollection->deleteIndex('stored');
$statementsCollection->deleteIndex(['lrs_id' => 1, 'stored' => -1]);
$statementsCollection->update([], ['$unset' => ["stored" => ""]], ['multiple' => true]);
$statementsCursor = $statementsCollection->find();
$remaining = $statementsCursor->count();
print $remaining . ' statements total' . PHP_EOL;
$maxBatchSize = 10000;
while ($statementsCursor->hasNext()) {
$batch = new MongoUpdateBatch($statementsCollection);
$batchSize = 0;
$shouldExecute = false;
while ($batchSize < $maxBatchSize && $statementsCursor->hasNext()) {
$batchSize++;
$statement = $statementsCursor->next();
if (isset($statement['refs'])) {
$query = ['q' => ['_id' => $statement['_id']], 'u' => ['$set' => []], 'multi' => false, 'upsert' => false];
foreach ($statement['refs'] as $key => $refStatement) {
if (isset($refStatement['timestamp']) && $refStatement['timestamp'] instanceof MongoDate) {
$query['u']['$set']['refs.' . $key . '.timestamp'] = date('Y-m-d\\TH:i:s.uP', $refStatement['timestamp']->sec);
}
if (isset($refStatement['stored']) && $refStatement['stored'] instanceof MongoDate) {
$query['u']['$set']['refs.' . $key . '.stored'] = date('Y-m-d\\TH:i:s.uP', $refStatement['stored']->sec);
}
}
if (!empty($query['u']['$set'])) {
$batch->add((object) $query);
$shouldExecute = true;
}
}
}
if ($shouldExecute) {
$batch->execute();
}
$remaining -= $batchSize;
print $remaining . ' remaining' . PHP_EOL;
}
}
开发者ID:learninglocker,项目名称:learninglocker,代码行数:46,代码来源:2015_12_23_093122_add_stored_to_statement_root.php
示例5: testDeleteIndexBroken
public function testDeleteIndexBroken()
{
$idx = $this->object->db->selectCollection('system.indexes');
$this->object->ensureIndex('foo');
$this->object->ensureIndex(array('foo' => -1));
$cursor = $idx->find(array('ns' => 'phpunit.c'));
$num = iterator_count($cursor);
$this->assertEquals(3, $num);
set_error_handler(array('MongoCollectionTest', 'errorHandler'));
try {
$this->object->deleteIndex(null);
} catch (Exception $e) {
$this->assertEquals("HANDLED: MongoCollection::deleteIndex(): The key needs to be either a string or an array", $e->getMessage());
}
restore_error_handler();
$num = iterator_count($idx->find(array('ns' => 'phpunit.c')));
$this->assertEquals(3, $num);
}
示例6: deleteIndex
/**
* Wrapper method for MongoCollection::deleteIndex().
*
* @see http://php.net/manual/en/mongocollection.deleteindex.php
* @param array|string $keys
* @return array
*/
public function deleteIndex($keys)
{
return $this->mongoCollection->deleteIndex($keys);
}
示例7: dropIndex
/**
* @param $name
*
* @return array
*/
public function dropIndex($name)
{
return $this->collection->deleteIndex($name);
}