• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP EMongoDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: current

 /**
  * Return the current element
  * @return EMongoDocument
  * @since v1.3.4
  */
 public function current()
 {
     $document = $this->_cursor->current();
     if (empty($document)) {
         return $document;
     }
     return $this->_model->populateRecord($document);
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:13,代码来源:EMongoCursor.php


示例2: getCursorAsArray

 public static function getCursorAsArray(EMongoDocument $model, $fn)
 {
     $useCursor = $model->getUseCursor();
     $model->setUseCursor(TRUE);
     $result = $fn($model)->getCursor();
     $model->setUseCursor($useCursor);
     return $result;
 }
开发者ID:bangkok,项目名称:CodeExample,代码行数:8,代码来源:MtModelFindAsArrayTrait.php


示例3: current

 /**
  * Gets the active record for the current row
  * @return EMongoDocument|mixed
  * @throws EMongoException
  */
 public function current()
 {
     if (!$this->run) {
         if ($this->model->getDbConnection()->queryCachingCount > 0 && $this->model->getDbConnection()->queryCachingDuration > 0 && $this->model->getDbConnection()->queryCacheID !== false && ($cache = Yii::app()->getComponent($this->model->getDbConnection()->queryCacheID)) !== null) {
             $this->model->getDbConnection()->queryCachingCount--;
             $info = $this->cursor()->info();
             $cacheKey = 'yii:dbquery' . $this->model->getDbConnection()->server . ':' . $this->model->getDbConnection()->db . ':' . $this->model->getDbConnection()->getSerialisedQuery(is_array($info['query']) && isset($info['query']['$query']) ? $info['query']['$query'] : array(), $info['fields'], is_array($info['query']) && isset($info['query']['$orderby']) ? $info['query']['$orderby'] : array(), $info['skip'], $info['limit']) . ':' . $this->model->getCollection();
             if (($result = $cache->get($cacheKey)) !== false) {
                 Yii::trace('Query result found in cache', 'extensions.MongoYii.EMongoDocument');
                 $this->cachedArray = $result;
                 $this->fromCache = true;
             } else {
                 $this->cachedArray = iterator_to_array($this->cursor);
             }
         }
         if (isset($cache, $cacheKey)) {
             $cache->set($cacheKey, $this->cachedArray, $this->model->getDbConnection()->queryCachingDuration, $this->model->getDbConnection()->queryCachingDependency);
             $this->fromCache = true;
         }
         $this->run = true;
     }
     if ($this->model === null) {
         throw new EMongoException(Yii::t('yii', 'The MongoCursor must have a model'));
     }
     if ($this->fromCache) {
         return $this->current = $this->model->populateRecord(current($this->cachedArray), true, $this->partial);
     }
     return $this->current = $this->model->populateRecord($this->cursor()->current(), true, $this->partial);
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:34,代码来源:EMongoCursor.php


示例4: current

 /**
  * Gets the active record for the current row
  * @return EMongoDocument|mixed
  * @throws EMongoException
  */
 public function current()
 {
     if ($this->model === null) {
         throw new EMongoException(Yii::t('yii', 'The MongoCursor must have a model'));
     }
     return $this->current = $this->model->populateRecord($this->cursor()->current(), true, $this->partial);
 }
开发者ID:kl0428,项目名称:admin,代码行数:12,代码来源:EMongoCursor.php


示例5: __construct

 /**
  * Constructor.
  * @param mixed $modelClass the model class (e.g. 'Post') or the model finder instance
  * (e.g. <code>Post::model()</code>, <code>Post::model()->published()</code>).
  * @param array $config configuration (name=>value) to be applied as the initial property values of this class.
  * @since v1.0
  */
 public function __construct($modelClass, $config = array())
 {
     if (is_string($modelClass)) {
         $this->modelClass = $modelClass;
         $this->model = EMongoDocument::model($modelClass);
     } else {
         if ($modelClass instanceof EMongoDocument) {
             $this->modelClass = get_class($modelClass);
             $this->model = $modelClass;
         } else {
             throw new EMongoException('Invalid model type for ' . __CLASS__);
         }
     }
     $this->_criteria = $this->model->getDbCriteria();
     if (isset($config['criteria'])) {
         $this->_criteria->mergeWith($config['criteria']);
         unset($config['criteria']);
     }
     $this->setId($this->modelClass);
     foreach ($config as $key => $value) {
         $this->{$key} = $value;
     }
     if ($this->keyField !== null && is_array($this->keyField)) {
         throw new EMongoException('This DataProvider cannot handle multi-field primary key.');
     } else {
         $this->keyField = '_id';
     }
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:35,代码来源:EMongoDocumentDataProvider.php


示例6: current

 /**
  * Gets the active record for the current row
  * @return EMongoDocument|mixed
  * @throws EMongoException
  */
 public function current()
 {
     if ($this->model === null) {
         return $this->current = $this->cursor->current();
     } else {
         return $this->current = $this->model->populateRecord($this->cursor->current(), true, $this->partial);
     }
 }
开发者ID:sammaye,项目名称:mongoyii-php7,代码行数:13,代码来源:Cursor.php


示例7: __construct

 /**
  * Creates the EMongoDataProvider instance
  * @param string|EMongoDocument $modelClass
  * @param array $config
  */
 public function __construct($modelClass, $config = array())
 {
     if (is_string($modelClass)) {
         $this->modelClass = $modelClass;
         $this->model = EMongoDocument::model($this->modelClass);
     } elseif ($modelClass instanceof EMongoDocument) {
         $this->modelClass = get_class($modelClass);
         $this->model = $modelClass;
     }
     $this->setId($this->modelClass);
     foreach ($config as $key => $value) {
         $this->{$key} = $value;
     }
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:19,代码来源:EMongoDataProvider.php


示例8: validateAttribute

 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     $className = $this->className === null ? get_class($object) : Yii::import($this->className);
     $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
     $finder = EMongoDocument::model($className);
     $criteria = array($attributeName => $this->mongoId ? new MongoId($value) : $value);
     if (!$finder->exists($criteria)) {
         $message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" is invalid.');
         $this->addError($object, $attribute, $message, array('{value}' => CHtml::encode($value)));
     }
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:21,代码来源:EMongoExistValidator.php


示例9: resolveLabel

 /**
  * @see CSort::resolveLabel()
  * @param string $attribute
  * @return string
  */
 public function resolveLabel($attribute)
 {
     $definition = $this->resolveAttribute($attribute);
     if (is_array($definition)) {
         if (isset($definition['label'])) {
             return $definition['label'];
         }
     } elseif (is_string($definition)) {
         $attribute = $definition;
     }
     if ($this->modelClass !== null) {
         return EMongoDocument::model($this->modelClass)->getAttributeLabel($attribute);
     }
     return $attribute;
 }
开发者ID:yiicod,项目名称:mongoyii,代码行数:20,代码来源:EMongoSort.php


示例10: validateAttribute

 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     $className = $this->className === null ? get_class($object) : Yii::import($this->className);
     $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
     // We get a RAW document here to prevent the need to make yet another active record instance
     $doc = EMongoDocument::model($className)->getCollection()->findOne(array_merge($this->criteria, [$attributeName => $this->caseSensitive ? $value : ['$regex' => $value, '$options' => 'i']]));
     // If a doc was fund and it isn't this doc, as decided by the primnary key
     if ($doc && (string) $doc[$object->primaryKey()] != (string) $object->getPrimaryKey()) {
         // Then it ain't unique
         $message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" has already been taken.');
         $this->addError($object, $attribute, $message, ['{value}' => CHtml::encode($value)]);
     } else {
     }
 }
开发者ID:yiicod,项目名称:mongoyii,代码行数:24,代码来源:EMongoUniqueValidator.php


示例11: validateAttribute

 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     $className = $this->className === null ? get_class($object) : Yii::import($this->className);
     $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
     // We get a RAW document here to prevent the need to make yet another active record instance
     $doc = EMongoDocument::model($className)->getCollection()->findOne(array_merge($this->criteria, array($attributeName => $this->caseSensitive ? $value : new MongoRegex('/' . $value . '/i'))));
     // If a doc was found first test if the unique attribute is the primaryKey
     // If we are uniquely id'ing the pk then check this is a new record and not
     // an old one and check to see if the pks are the same
     // If the found doc is not evaledd onm pk then make sure the two pks are not the same
     if ($doc && ($attributeName === $object->primaryKey() && $object->getIsNewRecord() && (string) $doc[$object->primaryKey()] == (string) $object->getPrimaryKey() || (string) $doc[$object->primaryKey()] != (string) $object->getPrimaryKey())) {
         // Then it ain't unique
         $message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" has already been taken.');
         $this->addError($object, $attribute, $message, array('{value}' => CHtml::encode($value)));
     } else {
     }
 }
开发者ID:koma136,项目名称:mongoyii,代码行数:27,代码来源:EMongoUniqueValidator.php


示例12: validateAttribute

 /**
  * Validates the attribute of the object.
  * If there is any error, the error message is added to the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && $this->isEmpty($value)) {
         return;
     }
     $className = $this->className === null ? get_class($object) : Yii::import($this->className);
     $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
     $finder = EMongoDocument::model($className);
     $criteria = new EMongoCriteria();
     $criteria->{$attribute} = $value;
     if ($this->criteria !== array()) {
         $criteria->mergeWith($this->criteria);
     }
     if (!$object instanceof EMongoDocument || $object->isNewRecord) {
         $exists = $finder->exists($criteria);
     } else {
         $criteria->limit = 2;
         $objects = $finder->findAll($criteria);
         $n = count($objects);
         if ($n === 1) {
             if ($column->isPrimaryKey) {
                 // primary key is modified and not unique
                 $exists = $object->getOldPrimaryKey() != $object->getPrimaryKey();
             } else {
                 // non-primary key, need to exclude the current record based on PK
                 $exists = $objects[0]->getPrimaryKey() != $object->getOldPrimaryKey();
             }
         } else {
             $exists = $n > 1;
         }
     }
     if ($exists) {
         $message = $this->message !== null ? $this->message : Yii::t('yii', '{attribute} "{value}" has already been taken.');
         $this->addError($object, $attribute, $message, array('{value}' => $value));
     }
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:43,代码来源:CMongoUniqueValidator.php


示例13: getRecord

 /**
  * Returns the specified EMongoDocument instance in the fixture data.
  * @param string $name the fixture name
  * @param string $alias the alias for the fixture data document
  * @return EMongoDocument the MongoDocument instance. False is returned
  * if there is no such fixture document.
  */
 public function getRecord($name, $alias)
 {
     if (isset($this->_records[$name][$alias])) {
         if (is_string($this->_records[$name][$alias])) {
             $row = $this->_rows[$name][$alias];
             $model = EMongoDocument::model($this->_records[$name][$alias]);
             $pk = $row['_id'];
             $this->_records[$name][$alias] = $model->findByPk($pk);
         }
         return $this->_records[$name][$alias];
     } else {
         return false;
     }
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:21,代码来源:EMongoDbFixtureManager.php


示例14: getWithParameters

 /**
  * Construct with parameter.
  *
  * @param \CActiveRecord|\EMongoDocument $model
  * @param bool $asIs if set this flag then relations array will return without filtering
  * @return array of relations parameters.
  */
 public function getWithParameters($model, $asIs = false)
 {
     if (isset($_GET[self::WITH])) {
         $temp = explode(",", \Yii::app()->request->getParam(self::WITH));
         if ($asIs) {
             return $temp;
         }
         foreach ($temp as $key => $value) {
             if (!isset($model->relations()[$value])) {
                 unset($temp[$key]);
             }
         }
         $temp = Filter::filterWithParameters($temp, get_class($model));
         return $temp;
     } else {
         return array();
     }
 }
开发者ID:JimmDiGriz,项目名称:HGApi,代码行数:25,代码来源:CoreApiController.php


示例15: guessNameColumn

 public function guessNameColumn(EMongoDocument $model)
 {
     foreach ($model->attributeNames() as $name) {
         if (!strcasecmp($name, 'name')) {
             return $name;
         }
     }
     foreach ($model->attributeNames() as $name) {
         if (!strcasecmp($name, 'title')) {
             return $name;
         }
     }
     foreach ($model->attributeNames() as $name) {
         if ($name == $model->primaryKey()) {
             return $name;
         }
     }
     return '_id';
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:19,代码来源:MongoCRUDCode.php


示例16: actionGetRequestInfo

 public function actionGetRequestInfo($className, $keyName, $key)
 {
     $requestModel = EMongoDocument::model($className)->findByAttributes(array($keyName => $key));
     $retArr = array();
     $widget = new CTextHighlighter();
     $widget->language = 'xml';
     $retArr['methodName'] = $requestModel->methodName;
     $retArr['requestXml'] = $widget->highlight($requestModel->requestXml);
     $retArr['responseXml'] = $widget->highlight($requestModel->responseXml);
     //$retArr['requestUrl'] = $requestModel->requestUrl;
     $retArr['timestamp'] = date("Y-m-d H:i:s", $requestModel->timestamp);
     $retArr['executionTime'] = Yii::app()->format->formatNumber($requestModel->executionTime);
     $retArr['errorDescription'] = $requestModel->errorDescription;
     echo json_encode($retArr);
     die;
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:16,代码来源:WorkflowStatesController.php


示例17: populateRecord

 /**
  * Creates an EMongoGridFS with the given attributes.
  * This method is internally used by the find methods.
  * @param MongoGridFSFile $document mongo gridFSFile
  * @param array $attributes attribute values (column name=>column value)
  * @param boolean $callAfterFind whether to call {@link afterFind} after the record is populated.
  * This parameter is added in version 1.0.3.
  * @return EMongoDocument the newly created document. The class of the object is the same as the model class.
  * Null is returned if the input data is false.
  * @since v1.3
  */
 public function populateRecord($document, $callAfterFind = true)
 {
     Yii::trace('Trace: ' . __CLASS__ . '::' . __FUNCTION__ . '()', 'ext.MongoDb.EMongoGridFS');
     if ($document instanceof MongoGridFSFile) {
         $model = parent::populateRecord($document->file, $callAfterFind);
         $model->_gridFSFile = $document;
         return $model;
     } else {
         return parent::populateRecord($document, $callAfterFind);
     }
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:22,代码来源:EMongoGridFS.php


示例18: __call

 /**
  * Magic will either call a function on the file if it exists or bubble to parent
  * @see EMongoDocument::__call()
  */
 public function __call($name, $parameters)
 {
     if ($this->getFile() instanceof MongoGridFSFile && method_exists($this->getFile(), $name)) {
         return call_user_func_array(array($this->getFile(), $name), $parameters);
     }
     return parent::__call($name, $parameters);
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:11,代码来源:EMongoFile.php


示例19: equals

 /**
  * Compares current active record with another one.
  * The comparison is made by comparing table name and the primary key values of the two active records.
  * @param EMongoDocument $record - record to compare to
  * @return boolean - whether the two active records refer to the same row in the database table.
  */
 public function equals($record)
 {
     return $this->collectionName() === $record->collectionName() && (string) $this->getPrimaryKey() === (string) $record->getPrimaryKey();
 }
开发者ID:pvassiliou,项目名称:MongoYii,代码行数:10,代码来源:EMongoDocument.php


示例20: offsetExists

 /**
  * Returns whether there is an element at the specified offset.
  * This method is required by the interface ArrayAccess.
  * @param mixed $offset the offset to check on
  * @return boolean
  */
 public function offsetExists($offset)
 {
     if (!isset($this->_array)) {
         foreach ($this->_cursor as $document) {
             $this->offsetSet(null, $this->_model->populateRecord($document));
         }
     }
     if (isset($this->_array[$offset])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:19,代码来源:EMongoCursor.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ESAPI类代码示例发布时间:2022-05-23
下一篇:
PHP EM_Object类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap