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


PHP MongoCollection::remove方法代码示例

本文整理汇总了PHP中MongoCollection::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoCollection::remove方法的具体用法?PHP MongoCollection::remove怎么用?PHP MongoCollection::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCollection的用法示例。


在下文中一共展示了MongoCollection::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteExceedingQuota

 public function deleteExceedingQuota($quota)
 {
     $threshold = 0.9 * $quota;
     $currentSize = $this->getPictureTotalSize();
     $counter = 0;
     if ($currentSize > $threshold) {
         $toPurge = $currentSize - $threshold;
         // cleaning
         $cursor = $this->collection->find(['-class' => 'picture'], ['storageKey' => true, 'size' => true])->sort(['_id' => 1]);
         // starting from older pictures
         $sum = 0;
         foreach ($cursor as $item) {
             if ($sum < $toPurge) {
                 $this->storage->remove($item['storageKey']);
                 $this->collection->remove(['_id' => $item['_id']]);
                 $sum += $item['size'];
                 $counter++;
             } else {
                 // when we have deleted enough old pictures to reach the exceeding size to purge
                 break;
             }
         }
     }
     return $counter;
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:25,代码来源:StorageQuota.php

示例2: purge

 /**
  */
 public function purge()
 {
     try {
         $this->_db->remove(array(self::TIMESTAMP => array('$lt' => time() - $this->_params['timeout'])));
     } catch (MongoException $e) {
         throw new Horde_Token_Exception($e);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:10,代码来源:Mongo.php

示例3: batchDeletePublish

 /**
  * Delete all Publishing content with their pk
  *
  * @param array $listing flat array given by the query above
  * @see self::findMostReportedPublish()
  */
 public function batchDeletePublish(array $listing)
 {
     $compilPk = [];
     foreach ($listing as $item) {
         $compilPk[] = $item['_id'];
     }
     $this->collection->remove(['_id' => ['$in' => $compilPk]]);
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:14,代码来源:AbuseReport.php

示例4: purge

 /**
  * {@inheritdoc}
  */
 public function purge()
 {
     if ($this->collection instanceof \MongoDB\Collection) {
         $this->collection->deleteMany(['expiration' => ['$lte' => time()]]);
     } else {
         $this->collection->remove(['expiration' => ['$lte' => time()]], ['multiple' => true]);
     }
     return true;
 }
开发者ID:Fiskie,项目名称:mongostash,代码行数:12,代码来源:MongoDB.php

示例5: gc

 public function gc($maxLifeTime)
 {
     $query = array('time' => array('$lt' => time() - $maxLifeTime));
     try {
         $this->collection->remove($query);
         return true;
     } catch (MongoCursorException $ex) {
         return false;
     }
 }
开发者ID:nourdine,项目名称:session,代码行数:10,代码来源:MongoSessionHandler.php

示例6: remove

 /**
  * Lets you remove documents based on a criteria
  * 
  * @param Array $criteria the conditions for removing documents
  */
 public function remove($criteria = array())
 {
     ValidatorsUtil::isNullOrEmpty($this->_mongoCollection, "Mongo collection isn't valid, have you set a collection?");
     $this->_mongoCollection->remove($criteria);
     $this->_count = 0;
     $this->_id = "";
 }
开发者ID:retrogamer4ever,项目名称:php-tools,代码行数:12,代码来源:MongoConnection.php

示例7: doRemove

 /**
  * Execute the remove query.
  *
  * @see Collection::remove()
  * @param array $query
  * @param array $options
  * @return array|boolean
  */
 protected function doRemove(array $query, array $options)
 {
     $options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
     $options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
     $options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
     return $this->mongoCollection->remove($query, $options);
 }
开发者ID:pmnyaga,项目名称:mongodb,代码行数:15,代码来源:Collection.php

示例8: _deleteOldEntries

 /**
  */
 protected function _deleteOldEntries($before)
 {
     try {
         $this->_db->remove(array(self::TS => array('$lt' => $before)));
     } catch (MongoException $e) {
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:9,代码来源:Mongo.php

示例9: delete

 /**
  * Deletes an item from the cache store.
  *
  * @param string $key The key to delete.
  * @return bool Returns true if the operation was a success, false otherwise.
  */
 public function delete($key)
 {
     if (!is_array($key)) {
         $criteria = array('key' => $key);
     } else {
         $criteria = $key;
     }
     $options = array('justOne' => false);
     if ($this->legacymongo) {
         $options['safe'] = $this->usesafe;
     } else {
         $options['w'] = $this->usesafe ? 1 : 0;
     }
     $result = $this->collection->remove($criteria, $options);
     if ($result === true) {
         // Safe mode.
         return true;
     } else {
         if (is_array($result)) {
             if (empty($result['ok']) || isset($result['err'])) {
                 return false;
             } else {
                 if (empty($result['n'])) {
                     // Nothing was removed.
                     return false;
                 }
             }
             return true;
         }
     }
     // Who knows?
     return false;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:39,代码来源:lib.php

示例10: delqueues

 /**
  * Added by me
  * 
  * Finds messages matching the query and removes from queue
  * @param array $query in same format as \MongoCollection::find() where top level fields do not contain operators.
  * Lower level fields can however. eg: valid {a: {$gt: 1}, "b.c": 3}, invalid {$and: [{...}, {...}]}
  * @param bool $logging whether logging is enabled or not 
  * @param array $logdata optional log data to be stored in _processed collection
  * @return void
  *
  * @throws \InvalidArgumentException key in $query was not a string
  */
 public function delqueues(array $query, $logging = false, $logdata = array())
 {
     if (!is_bool($logging)) {
         throw new \InvalidArgumentException('$logging was not a bool');
     }
     $removeQuery = array();
     foreach ($query as $key => $value) {
         if (!is_string($key)) {
             throw new \InvalidArgumentException('key in $query was not a string');
         }
         $removeQuery["payload.{$key}"] = $value;
     }
     if (count($removeQuery) > 0) {
         if ($logging && $this->_collection_processed != null) {
             $cursor = $this->_collection->find($removeQuery);
             foreach ($cursor as $doc) {
                 if ($doc !== null && array_key_exists('_id', $doc)) {
                     $deleted_message = array('payload' => $doc['payload'], 'log' => $logdata, 'pts' => new \MongoDate(), 'qd' => true);
                     $this->_collection_processed->insert($deleted_message);
                 }
             }
         }
         // remove queues
         $this->_collection->remove($removeQuery);
     }
 }
开发者ID:diffion,项目名称:php-mongo-queue,代码行数:38,代码来源:Queue.php

示例11: delete

 /**
  * Delete the object
  *
  */
 function delete()
 {
     if ($this->_collection && $this->_id) {
         $this->_collection->remove(array("_id" => $this->_id));
     }
     $this->_id = null;
     $this->_attrs = array();
 }
开发者ID:boosen,项目名称:rockmongo,代码行数:12,代码来源:RObject.php

示例12: remove

 /**
  * Deletes a document from the model's collection
  * @param array $criteria Description of records to remove.
  * @param array $options Options for remove. see @link http://www.php.net/manual/en/mongocollection.remove.php
  * @return mixed If "safe" is set, returns an associative array with the status of the remove ("ok"), the number of items removed ("n"), and any error that may have occured ("err"). Otherwise, returns TRUE if the remove was successfully sent, FALSE otherwise.
  * Throws MongoCursorException if the "safe" option is set and the remove fails. Throws MongoCursorTimeoutException if the "safe" option is set and the operation takes longer than MongoCursor::$timeout milliseconds to complete. This does not kill the operation on the server, it is a client-side timeout.
  */
 public function remove($criteria, $options = array())
 {
     if ($options === null) {
         $options = array();
     }
     $criteria = self::_sanitize($criteria);
     return $this->collection->remove($criteria, $options);
 }
开发者ID:mindaugas-valinskis,项目名称:doophp,代码行数:15,代码来源:DooMongoModel.php

示例13: gc

 /**
  * The garbage collection function invoked by PHP.
  * @param  int     $lifetime The lifetime param, defaults to 1440 seconds in PHP.
  * @return boolean True always.
  */
 public function gc($lifetime = 0)
 {
     $timeout = $this->getConfig('timeout');
     //find all sessions that are older than $timeout
     $olderThan = time() - $timeout;
     //no ack required
     $this->sessions->remove(array('last_accessed' => array('$lt' => new MongoDate($olderThan))), class_exists('MongoClient') ? array('w' => 0) : array('safe' => false));
     return true;
 }
开发者ID:nicktacular,项目名称:php-mongo-session,代码行数:14,代码来源:MongoSession.php

示例14: remove

 function remove($filter, $options = array())
 {
     br()->log()->writeln('MONGO->REMOVE', "QRY");
     br()->log()->writeln($filter, "FLT");
     br()->log()->writeln($options, "OPT");
     $result = parent::remove($filter, $options);
     br()->log()->writeln('Query complete', 'SEP');
     return $result;
 }
开发者ID:jagermesh,项目名称:bright,代码行数:9,代码来源:BrMongoDBProvider.php

示例15: gc

 /**
  */
 public function gc($maxlifetime = 300)
 {
     try {
         $this->_db->remove(array(self::MODIFIED => array('$lt' => time() - $maxlifetime)));
         return true;
     } catch (MongoException $e) {
     }
     return false;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:Mongo.php


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