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


PHP EMongoDocument::update方法代码示例

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


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

示例1: update

 /**
  * Updates the row represented by this active record.
  * All loaded attributes will be saved to the database.
  * Note, validation is not performed in this method. You may call {@link validate} to perform the validation.
  * @param array $attributes list of attributes that need to be saved. Defaults to null,
  * meaning all attributes that are loaded from DB will be saved.
  * @return boolean whether the update is successful
  * @throws EMongoException if the record is new
  * @since v1.3
  */
 public function update(array $attributes = null, $modify = false)
 {
     Yii::trace('Trace: ' . __CLASS__ . '::' . __FUNCTION__ . '()', 'ext.MongoDb.EMongoGridFS');
     if ($this->getIsNewRecord()) {
         throw new EMongoException(Yii::t('yii', 'The EMongoDocument cannot be updated because it is new.'));
     }
     if (is_file($this->filename) === true) {
         if ($this->deleteByPk($this->_id) !== false) {
             $result = $this->insertWithPk($this->_id, $attributes);
             if ($result === true) {
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         return parent::update($attributes, true);
     }
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:29,代码来源:EMongoGridFS.php

示例2: update

 /**
  * Updates the row represented by this active record.
  * All loaded attributes will be saved to the database.
  * Note, validation is not performed in this method. You may call {@link validate} to perform the validation.
  * @param array $attributes list of attributes that need to be saved. Defaults to null,
  * meaning all attributes that are loaded from DB will be saved.
  * @param boolean modify if set true only selected attributes will be replaced, and not
  * the whole document
  * @return boolean whether the update is successful
  * @throws CException if the record is new
  * @throws EMongoException on fail of update
  * @throws MongoCursorException on fail of update, when safe flag is set to true
  * @throws MongoCursorTimeoutException on timeout of db operation , when safe flag is set to true
  * @since v1.0
  */
 public function update(array $attributes = null, $modify = false)
 {
     if ($this->_partial) {
         $attributes = count($attributes) > 0 ? array_intersect($attributes, $this->_loadedFields) : array_diff($this->_loadedFields, array('_id'));
         return parent::update($attributes, true);
     }
     return parent::update($attributes, $modify);
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:23,代码来源:EMongoPartialDocument.php


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