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


PHP MongoCollection::update方法代码示例

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


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

示例1: save

 /**
  * Zapisuję dokonane zmiany w bazie
  *
  * @return	void
  */
 public function save()
 {
     $aMods = [];
     // dla modelu z modułami
     if ($this->aModules !== null) {
         // obsługa modułów
         foreach ($this->aModules as $mModule) {
             if (!$mModule instanceof Module) {
                 continue;
             }
             $aChanges = $mModule->beforeSave();
             $aMods[] = $mModule;
             if (!empty($aChanges)) {
                 $this->mergeChanges($aChanges);
             }
         }
     }
     $aChanges = $this->getChanges();
     // zapisuję jeśli się coś zmieniło
     if (!empty($aChanges)) {
         $this->oCollection->update(['_id' => $this->getId(true)], $this->getChanges());
         $this->clearChanges();
         // post save
         foreach ($aMods as $oModule) {
             $oModule->afterSave();
         }
     }
 }
开发者ID:pt-pl,项目名称:zf2-data-object,代码行数:33,代码来源:Document.php

示例2: set

 /**
  * Store the api $response as the cached result of the api $request.
  *
  * @param RequestInterface  $request    The request for which the response will be cached.
  * @param ResponseInterface $response   The reponse to cache.
  * @param integer  $timeToLive The time in seconds that the cache should live.
  *
  * @return void
  *
  * @throws \InvalidArgumentException Throw if $timeToLive is not an integer between 0 and 86400.
  */
 public function set(RequestInterface $request, ResponseInterface $response, $timeToLive = null)
 {
     $timeToLive = self::ensureTTL($timeToLive ?: $this->getDefaultTTL());
     $id = $request->getUrl();
     $cache = ['_id' => $id, 'httpCode' => $response->getHttpCode(), 'body' => $response->getBody(), 'headers' => $response->getHeaders(), 'expires' => new \MongoDate(time() + $timeToLive)];
     $this->collection->update(['_id' => $id], $cache, ['upsert' => true]);
 }
开发者ID:guillermoandrae,项目名称:marvel-api-client,代码行数:18,代码来源:MongoCache.php

示例3: update

 public function update(Kwf_Model_Row_Interface $row, $rowData)
 {
     $ret = $this->_collection->update(array('_id' => $row->_id), $rowData, array('safe' => true, 'multiple' => false));
     if (!$ret || $ret['ok'] != 1) {
         throw new Kwf_Exception("update failed");
     }
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:7,代码来源:Mongo.php

示例4: addDocument

 public function addDocument(Document $document)
 {
     $uniqueTokens = array_unique($document->tokens);
     foreach ($uniqueTokens as $token) {
         $this->index->update(["token" => $token], ['$push' => ["documents" => $document->id]], ["upsert" => true]);
     }
 }
开发者ID:markusos,项目名称:simple-search,代码行数:7,代码来源:MongoDBDocumentIndex.php

示例5: updateObject

 public function updateObject($object, ChangeSet $changeSet)
 {
     $data = $this->prepareUpdateChangeSet($object, $changeSet);
     unset($data['_id']);
     $this->mongoCollection->update($this->getObjectIdentifier($object), array('$set' => $data));
     return $data;
 }
开发者ID:basuritas-php,项目名称:skeleton-mapper,代码行数:7,代码来源:MongoDBObjectPersister.php

示例6: add

 /**
  */
 public function add($tokenID)
 {
     $data = array(self::ADDRESS => $this->_encodeRemoteAddress(), self::TID => $tokenID);
     try {
         $this->_db->update($data, array('$set' => array_merge($data, array(self::TIMESTAMP => time()))), array('upsert' => true));
     } catch (MongoException $e) {
         throw new Horde_Token_Exception($e);
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:11,代码来源:Mongo.php

示例7: set

 /**
  * {@inheritdoc }
  */
 public function set($key, $value, $ttl = null)
 {
     $tKey = $this->getKey($key);
     $tValue = $this->pack($value);
     if (!$ttl) {
         $ttl = $this->ttl;
     }
     $item = array('_id' => $tKey, 'value' => $tValue, 'ttl' => $this->getTtl($ttl));
     $this->collection->update(array('_id' => $tKey), $item, array('upsert' => true));
 }
开发者ID:evolutionscript,项目名称:Cache,代码行数:13,代码来源:Mongo.php

示例8: write

 /**
  * {@inheritdoc}
  */
 public function write($sessionId, $data)
 {
     $data = unserialize($data);
     // we don't save empty sessions
     if (isset($new_data['_sf2_attributes']) && count($new_data['_sf2_attributes']) === 0) {
         return true;
     }
     $this->collection->update(['_id' => $this->encodeSessionId($sessionId)], ['$set' => ['data' => $data, 'expireat' => new \MongoDate(time() + $this->ttl)]], ['upsert' => true, 'multiple' => false]);
     return true;
 }
开发者ID:Tanklong,项目名称:openvj,代码行数:13,代码来源:MongoDBSessionHandler.php

示例9: update

 public function update($entity, $options = ['multiple' => true])
 {
     $id = null;
     foreach (['id', '_id'] as $key) {
         if (isset($entity[$key])) {
             $id = (string) $entity[$key];
             unset($entity[$key]);
         }
     }
     $this->collection->update(['_id' => new MongoId($id)], ['$set' => $entity], $options);
 }
开发者ID:hoangpt,项目名称:nextcms,代码行数:11,代码来源:AbstractMapper.php

示例10: saveData

 /**
  * @param string $key Unique key for data that is results of action
  * @param array $data Results of actions
  * @return bool
  */
 public function saveData($key, array $data)
 {
     //@todo Это чтобы гарантировать наличие ключа. Потом возможно заменим это схемой документов
     $data['key'] = $key;
     $status = $this->dataCollection->update(['key' => $key], $data, ['upsert' => true]);
     if ($status['ok'] != 1) {
         $this->logger->error('Node data can not save', ['nodeName' => $this->name, 'dataKey' => $key, 'mongoStatus' => $status]);
         return false;
     }
     $this->logger->info('Node data saved', ['nodeName' => $this->name, 'dataKey' => $key]);
     return true;
 }
开发者ID:zarincheg,项目名称:celium,代码行数:17,代码来源:Node.php

示例11: doUpdate

 /**
  * Execute the update query.
  *
  * @see Collection::update()
  * @param array $query
  * @param array $newObj
  * @param array $options
  * @return array|boolean
  */
 protected function doUpdate(array $query, array $newObj, 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->update($query, $newObj, $options);
 }
开发者ID:im286er,项目名称:ent,代码行数:16,代码来源:Collection.php

示例12: save

 /**
  * Save current object to MongoDB
  *
  * @param boolean $refresh Should refresh the object fields values?
  * @return boolean
  */
 function save($refresh = false)
 {
     if (!$this->_collection) {
         import("@.RMongoException");
         throw new RMongoException("Object is not in any collection, please use setCollection() to method to set a collection.");
     }
     $bool = true;
     if ($this->_id) {
         //if exists
         if (!empty($this->_operations)) {
             $bool = $this->_collection->update(array("_id" => $this->_id), $this->_operations, array("upsert" => false, "multiple" => false));
             if ($refresh) {
                 $bool = $this->refresh();
             }
         }
     } else {
         $bool = $this->_collection->insert($this->_attrs, true);
         if ($bool) {
             $this->_id = $this->_attrs["_id"];
             import("@.RMongo");
             RMongo::setLastInsertId($this->_id->__toString());
         }
     }
     $this->_operations = array();
     return $bool;
 }
开发者ID:boosen,项目名称:rockmongo,代码行数:32,代码来源:RObject.php

示例13: write

 /**
  * This writes to memory. 
  * After returning PHP will invoke SessionHandler::close.
  * 
  * @param string $sessionId
  * @param string $data Serialized shit
  * @return boolean
  */
 public function write($sessionId, $data)
 {
     $query = array("session-id" => $sessionId);
     $toSave = array_merge($query, array("data" => $data, "time" => time()));
     try {
         $el = $this->collection->findOne($query);
         if ($el === null) {
             $result = $this->collection->save($toSave);
         } else {
             $result = $this->collection->update($query, $toSave);
         }
         return $result["ok"] == 1;
     } catch (MongoCursorException $ex) {
         return false;
     }
 }
开发者ID:nourdine,项目名称:session,代码行数:24,代码来源:MongoSessionHandler.php

示例14: write

 /**
  * Write Session - commit data to resource
  *
  * @param string $id
  * @param mixed  $data
  */
 public function write($id, $data)
 {
     try {
         if (empty($_SESSION)) {
             $this->destroy($id);
             return;
         }
         $exists = isset($this->_sessionHashes[$id]);
         $modified = $exists && $this->_sessionHashes[$id] !== md5($data);
         if (!$exists || $modified) {
             $filter = array('_id' => $id);
             $options = array('upsert' => true, 'multiple' => false);
             $update = array('data' => $data, 'metadata.created' => new MongoDate(time()), 'rawData' => $_SESSION);
             if (!$exists) {
                 $update['metadata.expire'] = new MongoDate(time() + $this->_maxLifeTime);
             }
             \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('session'));
             $result = $this->_collection->update($filter, array('$set' => $update), $options);
             if ($result['ok'] == 1) {
                 return true;
             }
         } else {
             return true;
         }
     } catch (Exception $e) {
         \App::log()->crit($e);
     }
     return false;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:35,代码来源:Mongo.php

示例15: doUpdate

 protected function doUpdate($query, array $newObj, array $options)
 {
     if (is_scalar($query)) {
         $query = array('_id' => $query);
     }
     return $this->mongoCollection->update($query, $newObj, $options);
 }
开发者ID:rybakit,项目名称:mongodb,代码行数:7,代码来源:Collection.php


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