當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。