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


PHP Mongo::getInstance方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * Establishes a Config instance for all children to enjoy
  */
 public function __construct()
 {
     // @todo Lazy load these so we're not loading them on every instance
     $this->config = Config::getInstance();
     $this->mongo = Mongo::getInstance();
     //$this->redis  = Redis::getInstance();
     // Optionally logs the constructor to the profiler
     if ($this->config['profiler']) {
         Profiler::log($this, '__construct');
     }
 }
开发者ID:joshtronic,项目名称:pickles,代码行数:16,代码来源:Object.php

示例2: find

 /**
  * @param array $query
  * @param array $sort
  * @param null|int $limit
  * @param null|int $skip
  * @return array
  */
 public function find(array $query = array(), array $sort = array(), $limit = null, $skip = null)
 {
     if (!Mongo::getInstance()->isAuthDisabled()) {
         // TODO: add support for $and and $or queries
         if (isset($query['className'])) {
             if (is_array($query['className']) && !empty($query['className']['$in'])) {
                 $newIn = array();
                 foreach ($query['className']['$in'] as $className) {
                     if (Mongo::getInstance()->getUser()->can($className, 'read')) {
                         $newIn[] = $className;
                     }
                 }
                 if (empty($newIn)) {
                     return array();
                 }
                 $query['className']['$in'] = $newIn;
             } elseif (is_string($query['className']) && !Mongo::getInstance()->getUser()->can($query['className'], 'read')) {
                 return array();
             }
         } else {
             $query['className'] = array('$in' => Mongo::getInstance()->getUser()->getPermissions('read'));
         }
     }
     $cursor = $this->_getCollection()->find($query);
     if (!empty($sort)) {
         try {
             $cursor->sort($sort);
         } catch (\Exception $e) {
             // continue with unsorted cursor
         }
     }
     if (!is_null($limit)) {
         $cursor->limit(intval($limit));
     }
     if (!is_null($skip)) {
         $cursor->skip(intval($skip));
     }
     $results = array();
     foreach ($cursor as $r) {
         if (empty($r['className'])) {
             // TODO: logging
             continue;
         }
         $results[] = Mongo::factory($r['className'], $r);
     }
     return $results;
 }
开发者ID:trashf,项目名称:jormakalevi,代码行数:54,代码来源:Document.php

示例3: can

 /**
  * Checks if user can perform an operation.
  *
  * @param string $className
  * @param string $operation
  * @return bool
  */
 public function can($className, $operation)
 {
     if (Mongo::getInstance()->isAuthDisabled()) {
         return true;
     }
     return in_array($className, $this->getPermissions($operation));
 }
开发者ID:trashf,项目名称:jormakalevi,代码行数:14,代码来源:User.php


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