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


PHP MongoCollection::findOne方法代码示例

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


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

示例1: findOne

 public function findOne($email)
 {
     $one = $this->contactsManagerCollection->findOne(array('email' => $email));
     if ($one != null) {
         return $this->createContact($one);
     }
 }
开发者ID:lga37,项目名称:contacts,代码行数:7,代码来源:ContactMongoStorage.php

示例2: get

 /**
  * Get data by key if not expired
  * @param $key
  * @return string
  */
 protected function get($key)
 {
     $record = $this->mongoCollection->findOne(array('key' => $key));
     if ($record && is_array($record) && array_key_exists('data', $record)) {
         return $record['data'];
     }
 }
开发者ID:rafabrutaldrums,项目名称:casamacario,代码行数:12,代码来源:MongoDB.php

示例3: getLogById

 /**
  * Retrieve a log entry by his ID.
  *
  * @param string $id
  *
  * @return Log|null
  */
 public function getLogById($id)
 {
     $log = $this->collection->findOne(array('_id' => array('$eq' => new \MongoId($id))));
     if (!$log) {
         return null;
     }
     return $this->convertArrayToEntity($log);
 }
开发者ID:jhamilton86,项目名称:MongologBrowserBundle,代码行数:15,代码来源:LogRepository.php

示例4: findByEmail

 /**
  * {@inheritdoc}
  */
 public function findByEmail(EmailAddress $email)
 {
     $persistedState = $this->collection->findOne(['email' => (string) $email]);
     if ($persistedState === null) {
         return null;
     }
     return AccountCredentials::fromPersistedState($persistedState);
 }
开发者ID:gobudgit,项目名称:gobudgit,代码行数:11,代码来源:MongoAccountCredentialsRepository.php

示例5: read

 /**
  * Read Session Data
  *
  * @param string $id
  *   Session Data ID
  *
  * @return string|NULL
  *
  * If the fetching process was successfully completed and read data
  * is not corrupted, a string will be returned.
  *
  * Otherwise, NULL will
  */
 public function read($id)
 {
     $data = $this->collection->findOne(array('_id' => $id), array('serialized'));
     if (isset($data['serialized']) && $data['serialized'] instanceof \MongoBinData) {
         return gzuncompress($data['serialized']->bin);
     }
     return NULL;
 }
开发者ID:nextframework,项目名称:next,代码行数:21,代码来源:Mongo.php

示例6: exists

 /**
  */
 public function exists($tokenID)
 {
     try {
         return !is_null($this->_db->findOne(array(self::ADDRESS => $this->_encodeRemoteAddress(), self::TID => $tokenID)));
     } catch (MongoException $e) {
         return false;
     }
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:10,代码来源:Mongo.php

示例7: get

 /**
  * Retrieve the cached results of the api $request.
  *
  * @param RequestInterface $request A request for which the response may be cached.
  *
  * @return ResponseInterface|null
  */
 public function get(RequestInterface $request)
 {
     $cached = $this->collection->findOne(['_id' => $request->getUrl()]);
     if ($cached === null) {
         return null;
     }
     return new Response($cached['httpCode'], $cached['headers'], $cached['body']);
 }
开发者ID:guillermoandrae,项目名称:marvel-api-client,代码行数:15,代码来源:MongoCache.php

示例8: get

 /**
  * Retrieves the cache item for the given id.
  *
  * @param  string     $key The cache key to retrieve.
  * @return mixed|null Returns the cached data or null.
  */
 public function get($key)
 {
     $cache = $this->collection->findOne(array('key' => $key), array('data', 'expire'));
     if ($cache !== null) {
         $this->ttls[$key] = isset($cache['expire']) ? $cache['expire']->sec - time() : 0;
     }
     return $cache;
 }
开发者ID:MacFJA,项目名称:apix-cache,代码行数:14,代码来源:Mongo.php

示例9: getLockInfo

 /**
  */
 public function getLockInfo($lockid)
 {
     $query = array(self::LID => $lockid, '$or' => array(array(self::EXPIRY_TS => array('$gte' => time())), array(self::EXPIRY_TS => Horde_Lock::PERMANENT)));
     try {
         return $this->_mapFields($this->_db->findOne($query));
     } catch (MongoException $e) {
         throw new Horde_Lock_Exception($e);
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:11,代码来源:Mongo.php

示例10: getGroup

 protected function getGroup($identifier)
 {
     $res = $this->collection->findOne([self::FIELD_TYPE => self::RECORD_TYPE_KEYWORD, self::FIELD_IDENTIFIER => $identifier]);
     if ($res) {
         return $res[self::FIELD_GROUP];
     } else {
         throw new \RuntimeException('Could not get group name. Identifier is not subscribed');
     }
 }
开发者ID:ephrin,项目名称:samples,代码行数:9,代码来源:SuppressorMongo.php

示例11: findOne

 public function findOne($criteria)
 {
     $result = null;
     $document = $this->mongoCollection->findOne($criteria);
     if ($document) {
         $result = $this->objectFactory->unmarshal($document);
     }
     return $result;
 }
开发者ID:dav-m85,项目名称:simple-mongo,代码行数:9,代码来源:Collection.php

示例12: search

 public function search($query)
 {
     $results = [];
     $data = $this->index->findOne(array('token' => $query));
     if (!isset($data)) {
         return $results;
     }
     return $data['documents'];
 }
开发者ID:markusos,项目名称:simple-search,代码行数:9,代码来源:MongoDBDocumentIndex.php

示例13: insertOrUpdate

 public function insertOrUpdate($product)
 {
     $result = $this->collection->findOne(['product_id' => $product['product_id']]);
     if ($result) {
         $this->update($product);
     } else {
         $this->insert($product);
     }
 }
开发者ID:lukaszm-rc,项目名称:dev-tools,代码行数:9,代码来源:MongoBulk.php

示例14: isCached

 /**
  * {@inheritDoc}
  */
 public function isCached($providerName, $query)
 {
     $result = $this->collection->findOne(array('id' => $this->getKey($providerName, $query)));
     if (null === $result) {
         return false;
     }
     $cached = new BatchGeocoded();
     $cached->fromArray($result);
     return $cached;
 }
开发者ID:vanslambrouckd,项目名称:geotools,代码行数:13,代码来源:MongoDB.php

示例15: get

 /**
  * {@inheritdoc }
  */
 public function get($key)
 {
     $tKey = $this->getKey($key);
     $tNow = $this->getTtl();
     $data = $this->collection->findOne(array('_id' => $tKey, 'ttl' => array('$gte' => $tNow)));
     if (isset($data)) {
         return $this->unPack($data['value']);
     }
     return false;
 }
开发者ID:evolutionscript,项目名称:Cache,代码行数:13,代码来源:Mongo.php


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