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


PHP Model::updateAll方法代码示例

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


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

示例1: afterSave

 public function afterSave(Model $model, $created, $options = array())
 {
     if ($model->data[$model->alias]['main'] != '0') {
         // if main was set as 1.. set the rest to 0
         $model->updateAll(array($model->alias . '.main' => "0"), array($model->alias . '.contact_type_id = ' => $model->data[$model->alias]['contact_type_id'], $model->alias . '.id <> ' => $model->id, $model->alias . '.security_user_id = ' => $model->data[$model->alias]['security_user_id']));
     }
     return parent::afterSave($model, $created, $options);
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:8,代码来源:ContactBehavior.php

示例2: updateAll

 public function updateAll($fields, $conditions = true)
 {
     $this->useDbConfig = 'master';
     $status = parent::updateAll($fields, $conditions);
     if (!isset($_SERVER['FORCEMASTER'])) {
         $this->useDbConfig = 'default';
     }
     return $status;
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:9,代码来源:AppModel.php

示例3: updateAll

 function updateAll($fields, $conditions = true, $recursive = null)
 {
     if (!isset($recursive)) {
         $recursive = $this->recursive;
     }
     if ($recursive == -1) {
         $this->unbindModel(array('belongsTo' => array_keys($this->belongsTo), 'hasOne' => array_keys($this->hasOne)), true);
     }
     return parent::updateAll($fields, $conditions);
 }
开发者ID:sing-group,项目名称:Markyt,代码行数:10,代码来源:AppModel.php

示例4: updateAll

 /**
  * {@inheritDoc}
  */
 public function updateAll($fields, $conditions = true)
 {
     $e = null;
     if ($this->_stopwatch) {
         $e = $this->_getStopwatchEvent('updateAll');
     }
     $result = parent::updateAll($fields, $conditions);
     if ($e !== null) {
         $e->stop();
     }
     return $result;
 }
开发者ID:ezoterik,项目名称:cakephp-pinba-plugin,代码行数:15,代码来源:TimerModel.php

示例5: updateBbsArticleChildCount

 /**
  * Update bbs_article_child_count
  *
  * @param object $model instance of model
  * @param int $rootId RootId for root BbsArticle
  * @param int $languageId languages.id
  * @return mixed On success Model::$data if its not empty or true, false on failure
  * @throws InternalErrorException
  */
 public function updateBbsArticleChildCount(Model $model, $rootId, $languageId)
 {
     $rootId = (int) $rootId;
     $conditions = array('BbsArticleTree.root_id' => $rootId, 'BbsArticle.language_id' => $languageId, 'BbsArticle.is_active' => true);
     $count = $model->find('count', array('recursive' => 0, 'conditions' => $conditions));
     if ($count === false) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
     $update = array('BbsArticleTree.bbs_article_child_count' => $count);
     $conditions = array('BbsArticleTree.id' => $rootId);
     if (!$model->updateAll($update, $conditions)) {
         throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
     }
 }
开发者ID:Onasusweb,项目名称:Bbses,代码行数:23,代码来源:BbsArticleBehavior.php

示例6: updateAll

 /**
  * Updates multiple model records based on a set of conditions.
  *
  * call afterSave() callback after successful update.
  *
  * @param array $fields     Set of fields and values, indexed by fields.
  *                          Fields are treated as SQL snippets, to insert literal values manually escape your data.
  * @param mixed $conditions Conditions to match, true for all records
  * @return boolean True on success, false on failure
  * @access public
  */
 function updateAll($fields, $conditions = true)
 {
     $output = parent::updateAll($fields, $conditions);
     if ($output) {
         $created = false;
         $options = array();
         $this->Behaviors->trigger($this, 'afterSave', array($created, $options));
         $this->afterSave($created);
         $this->_clearCache();
         $this->id = false;
         return true;
     }
     return false;
 }
开发者ID:post2web,项目名称:croogo,代码行数:25,代码来源:app_model.php

示例7: beforeSave

 public function beforeSave(Model $model, $options = array())
 {
     $schema = $model->schema();
     $data = current($model->data);
     if (isset($schema['default']) && isset($data['default'])) {
         // because they are still in their own tables..
         // $conditionId = $model->getConditionId();
         $default = $data['default'];
         if ($default == 1) {
             $model->updateAll(array($model->alias . '.default' => 0));
         }
     }
     return true;
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:14,代码来源:FieldOptionBehavior.php

示例8: _updateRecord

 /**
  * Updates a database record with the necessary extra data
  *
  * @param Model $model Model instance
  * @param array $data array containing data to be saved to the record
  * @return void
  */
 protected function _updateRecord(Model $model, $data)
 {
     if (!empty($data[$model->alias])) {
         $model->updateAll($data[$model->alias], array($model->alias . '.' . $model->primaryKey => $model->id));
     }
 }
开发者ID:hotanlam,项目名称:japansource,代码行数:13,代码来源:UploadBehavior.php

示例9: changeCommentCount

 /**
  * Increment or decrement the comment count cache on the associated model
  *
  * @param Object $model Model to change count of
  * @param mixed $id The id to change count of
  * @param string $direction 'up' or 'down'
  * @return null
  */
 public function changeCommentCount(Model $model, $id = null, $direction = 'up')
 {
     if ($model->hasField('comments')) {
         if ($direction == 'up') {
             $direction = '+ 1';
         } elseif ($direction == 'down') {
             $direction = '- 1';
         } else {
             $direction = null;
         }
         $model->id = $id;
         if (!is_null($direction) && $model->exists(true)) {
             return $model->updateAll(array($model->alias . '.comments' => $model->alias . '.comments ' . $direction), array($model->alias . '.id' => $id));
         }
     }
     return false;
 }
开发者ID:radig,项目名称:comments,代码行数:25,代码来源:CommentableBehavior.php

示例10: __incrementPositionsOnLowerItems

 /**
  * Moves all lower items one position down
  *
  * @param object AppModel
  * @param integer
  * @return boolean
  */
 private function __incrementPositionsOnLowerItems(Model $model, $position)
 {
     extract($this->settings[$model->alias]);
     $positionColumn = $this->settings[$model->alias]['positionColumn'];
     return $model->updateAll(array($model->alias . '.' . $positionColumn => $model->alias . '.' . $positionColumn . '+1'), array($this->__scopeCondition($model), $model->alias . '.' . $positionColumn . ' >= ' => $position));
 }
开发者ID:tetsuo111,项目名称:cakephp,代码行数:13,代码来源:ListBehavior.php

示例11: updateAll

 /**
  * Updates multiple model records based on a set of conditions.
  *
  * @param array $fields Set of fields and values, indexed by fields.
  * 	Fields are treated as SQL snippets, to insert literal values manually escape your data.
  * @param mixed $conditions Conditions to match, true for all records
  * @return boolean True on success, false on failure
  * @link http://book.cakephp.org/view/75/Saving-Your-Data
  */
 public function updateAll($fields, $conditions = true)
 {
     $result = parent::updateAll($fields, $conditions);
     if ($result) {
         if ($this->Behaviors->attached('BcCache') && $this->Behaviors->enabled('BcCache')) {
             $this->delCache($this);
         }
     }
     return $result;
 }
开发者ID:kenz,项目名称:basercms,代码行数:19,代码来源:BcAppModel.php

示例12: updateAll

 /**
  * Updates multiple model records based on a set of conditions.
  *
  * @param array $fields Set of fields and values, indexed by fields.
  *    Fields are treated as SQL snippets, to insert literal values manually escape your data.
  * @param mixed $conditions Conditions to match, true for all records
  * @return boolean True on success, false on failure
  * @access public
  * @link http://book.cakephp.org/view/75/Saving-Your-Data
  */
 function updateAll($fields, $conditions = true)
 {
     $result = parent::updateAll($fields, $conditions);
     if ($result) {
         if ($this->Behaviors->attached('Cache') && $this->Behaviors->enabled('Cache')) {
             if ($this->cacheEnabled()) {
                 $this->cacheDelete($this);
             }
         }
     }
     return $result;
 }
开发者ID:nojimage,项目名称:basercms,代码行数:22,代码来源:baser_app_model.php

示例13: beforeSave

 /**
  * Sets the weight for new items so they end up at end
  *
  * @todo add new model with weight. clean up after
  * @param Model $Model
  */
 public function beforeSave(&$Model)
 {
     //	Check if weight id is set. If not add to end, if set update all
     // rows from ID and up
     if (!isset($Model->data[$Model->alias][$Model->primaryKey]) || isset($Model->data[$Model->alias][$this->settings[$Model->alias]['field']]) && !is_numeric($Model->data[$Model->alias][$this->settings[$Model->alias]['field']]) || $this->settings[$Model->alias]['foreign_key'] && isset($Model->data[$Model->alias][$this->settings[$Model->alias]['foreign_key']]) && $Model->data[$Model->alias][$this->settings[$Model->alias]['foreign_key']] != $Model->field($this->settings[$Model->alias]['foreign_key'])) {
         $fk = null;
         if ($this->settings[$Model->alias]['foreign_key']) {
             if (!isset($Model->data[$Model->alias][$this->settings[$Model->alias]['foreign_key']])) {
                 trigger_error('OrderedBehavior : New rows must be saved with foreign key field present.', E_USER_WARNING);
                 return false;
             }
             $fk = $Model->data[$Model->alias][$this->settings[$Model->alias]['foreign_key']];
             // foreign_key changed
             if ($fk != $Model->field($this->settings[$Model->alias]['foreign_key'])) {
                 // move down all items with old foreign_key and weight > weight of changed item
                 $conditions = array($Model->alias . '.' . $this->settings[$Model->alias]['foreign_key'] => $Model->field($this->settings[$Model->alias]['foreign_key']), $Model->alias . '.' . $this->settings[$Model->alias]['field'] . ' >' => $Model->field($this->settings[$Model->alias]['field']));
                 $Model->updateAll(array($this->settings[$Model->alias]['field'] => $Model->alias . '.' . $this->settings[$Model->alias]['field'] . ' - 1'), $conditions);
             }
         }
         $Model->data[$Model->alias][$this->settings[$Model->alias]['field']] = $this->_newWeight($Model, $fk);
     }
     return true;
 }
开发者ID:vuthaiphat,项目名称:CakePHP-Assets,代码行数:29,代码来源:ordered.php

示例14: removeFromTree

 /**
  * Remove the current node from the tree, and reparent all children up one level.
  *
  * If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
  * after the children are reparented.
  *
  * @param Model $Model Model instance
  * @param mixed $id The ID of the record to remove
  * @param boolean $delete whether to delete the node after reparenting children (if any)
  * @return boolean true on success, false on failure
  * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::removeFromTree
  */
 public function removeFromTree($Model, $id = null, $delete = false)
 {
     if (is_array($id)) {
         extract(array_merge(array('id' => null), $id));
     }
     extract($this->settings[$Model->alias]);
     list($node) = array_values($Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $id), 'fields' => array($Model->primaryKey, $left, $right, $parent), 'recursive' => $recursive)));
     if ($node[$right] == $node[$left] + 1) {
         if ($delete) {
             return $Model->delete($id);
         } else {
             $Model->id = $id;
             return $Model->saveField($parent, null);
         }
     } elseif ($node[$parent]) {
         list($parentNode) = array_values($Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $node[$parent]), 'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive)));
     } else {
         $parentNode[$right] = $node[$right] + 1;
     }
     $db = ConnectionManager::getDataSource($Model->useDbConfig);
     $Model->updateAll(array($parent => $db->value($node[$parent], $parent)), array($Model->escapeField($parent) => $node[$Model->primaryKey]));
     $this->_sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
     $this->_sync($Model, 2, '-', '> ' . $node[$right]);
     $Model->id = $id;
     if ($delete) {
         $Model->updateAll(array($Model->escapeField($left) => 0, $Model->escapeField($right) => 0, $Model->escapeField($parent) => null), array($Model->escapeField() => $id));
         return $Model->delete($id);
     } else {
         $edge = $this->_getMax($Model, $scope, $right, $recursive);
         if ($node[$right] == $edge) {
             $edge = $edge - 2;
         }
         $Model->id = $id;
         return $Model->save(array($left => $edge + 1, $right => $edge + 2, $parent => null), array('callbacks' => false));
     }
 }
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:48,代码来源:TreeBehavior.php

示例15: _recoverByParentId

 /**
  * _recoverByParentId
  *
  * Recursive helper function used by recover
  *
  * @param Model $Model Model instance.
  * @param int $counter Counter
  * @param int|string|null $parentId Parent record Id
  * @return int counter
  */
 protected function _recoverByParentId(Model $Model, $counter = 1, $parentId = null)
 {
     $params = array('conditions' => array($this->settings[$Model->alias]['parent'] => $parentId), 'fields' => array($Model->primaryKey), 'page' => 1, 'limit' => 100, 'order' => array($Model->primaryKey));
     $scope = $this->settings[$Model->alias]['scope'];
     if ($scope && ($scope !== '1 = 1' && $scope !== true)) {
         $params['conditions'][] = $scope;
     }
     $children = $Model->find('all', $params);
     $hasChildren = (bool) $children;
     if ($parentId !== null) {
         if ($hasChildren) {
             $Model->updateAll(array($this->settings[$Model->alias]['left'] => $counter), array($Model->escapeField() => $parentId));
             $counter++;
         } else {
             $Model->updateAll(array($this->settings[$Model->alias]['left'] => $counter, $this->settings[$Model->alias]['right'] => $counter + 1), array($Model->escapeField() => $parentId));
             $counter += 2;
         }
     }
     while ($children) {
         foreach ($children as $row) {
             $counter = $this->_recoverByParentId($Model, $counter, $row[$Model->alias][$Model->primaryKey]);
         }
         if (count($children) !== $params['limit']) {
             break;
         }
         $params['page']++;
         $children = $Model->find('all', $params);
     }
     if ($parentId !== null && $hasChildren) {
         $Model->updateAll(array($this->settings[$Model->alias]['right'] => $counter), array($Model->escapeField() => $parentId));
         $counter++;
     }
     return $counter;
 }
开发者ID:mgoo,项目名称:MovieServer,代码行数:44,代码来源:TreeBehavior.php


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