当前位置: 首页>>代码示例>>PHP>>正文


PHP MongoCollection::deleteIndex方法代码示例

本文整理汇总了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;
 }
开发者ID:danielheyman,项目名称:TechDimeProjects,代码行数:21,代码来源:Blueprint.php

示例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);
    }
开发者ID:neurodrone,项目名称:mongo-php-driver,代码行数:26,代码来源:MongoCollectionTest.php

示例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;
 }
开发者ID:robo47,项目名称:mandango,代码行数:11,代码来源:LoggableMongoCollection.php

示例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);
 }
开发者ID:kph11,项目名称:mongo-php-driver,代码行数:18,代码来源:MongoCollectionTest.php

示例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);
 }
开发者ID:pmnyaga,项目名称:mongodb,代码行数:11,代码来源:Collection.php

示例7: dropIndex

 /**
  * @param $name
  *
  * @return array
  */
 public function dropIndex($name)
 {
     return $this->collection->deleteIndex($name);
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:9,代码来源:MongoGateway.php


注:本文中的MongoCollection::deleteIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。