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


PHP AppModel::saveField方法代码示例

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


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

示例1: setStatus

 /**
  * One-purpose method for switching statuses
  *
  * @param AppModel $Model
  * @param string $status
  * @param string $id
  * @return boolean
  */
 public function setStatus($Model, $status, $id = null)
 {
     if ($id) {
         $Model->id = $id;
     }
     return $Model->saveField('status', $status, true);
 }
开发者ID:hadzi,项目名称:brekfarm,代码行数:15,代码来源:status.php

示例2: 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 AppModel $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
  * @access public
  * @link http://book.cakephp.org/view/1354/removeFromTree
  */
 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($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:ale3andro,项目名称:metathesi,代码行数:49,代码来源:tree.php

示例3: 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 AppModel $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
  */
 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($parent => $node[$Model->primaryKey]));
     $Model->id = $id;
     $this->__sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
     $this->__sync($Model, 2, '-', '> ' . $node[$right]);
     if ($delete) {
         $sub_tree = $Model->find('list', array('conditions' => array($left . ' >= ' . $node[$left], $right . ' <= ' . $node[$right]), 'fields' => array('id', 'parent_id')));
         foreach ($sub_tree as $sChild => $sParent) {
             $Model->del($sChild);
         }
         return true;
     } else {
         /*
          * this could feasibly create a lot of new trees.. worst case
          * performance slightly worse than original
          */
         $edge = $this->__getPartition($Model, $scope, $recursive);
         if ($node[$right] == $edge) {
             $edge = $edge - 2;
         }
         $Model->id = $id;
         return $Model->save(array($left => $edge, $right => $edge + 1, $parent => null), array('callbacks' => false));
     }
 }
开发者ID:neterslandreau,项目名称:goinggreen,代码行数:54,代码来源:btree.php

示例4: setparent

 /**
  * Backward compatible method
  *
  * Returns true if the change is successful.
  *
  * @param AppModel $model
  * @param mixed $parentId The ID to set as the parent of the current node.
  * @return true on success
  * @access public
  */
 function setparent(&$model, $parentId = null, $created = null)
 {
     extract($this->settings[$model->alias]);
     if ($created === false && $parentId == $model->field($parent)) {
         return true;
     }
     return $model->saveField($parent, $parentId);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:18,代码来源:tree.php

示例5: setparent

 /**
  * Backward compatible method
  *
  * Returns true if the change is successful.
  *
  * @param AppModel $model
  * @param mixed $parentId The ID to set as the parent of the current node.
  * @return true on success
  * @access public
  * @deprecated
  */
 function setparent(&$model, $parentId = null, $created = null)
 {
     trigger_error(__('(TreeBehavior::setParent) Deprecated - save the record with a parent ID instead', true), E_USER_ERROR);
     extract($this->settings[$model->alias]);
     if ($created === false && $parentId == $model->field($parent)) {
         return true;
     }
     return $model->saveField($parent, $parentId, array('callbacks' => false));
 }
开发者ID:BLisa90,项目名称:cakecart,代码行数:20,代码来源:tree.php

示例6: moveup

 /**
  * Move up element
  *
  * @param AppModel $Model Model instance
  * @param mixed $id The ID of the record to move
  * @param mixed $number how many places to move the node, or true to move to first position
  * @return boolean true on success, false on failure
  */
 public function moveup(&$Model, $id = null, $number = 1)
 {
     if (is_array($id)) {
         extract(array_merge(array('id' => null), $id));
     }
     if (!$number) {
         return false;
     }
     if (empty($id)) {
         $id = $Model->id;
     }
     $data = $Model->read(am($this->settings[$Model->alias]['order_field'], $this->settings[$Model->alias]['group_fields']), $id);
     $order = $data[$Model->alias][$this->settings[$Model->alias]['order_field']];
     if (is_int($number)) {
         $order -= abs($number);
     } elseif ($number === true) {
         $order = $this->settings[$Model->alias]['start_at'];
     } else {
         return false;
     }
     if ($order < $this->settings[$Model->alias]['start_at']) {
         $order = $this->settings[$Model->alias]['start_at'];
     }
     $Model->id = $id;
     return $Model->saveField($this->settings[$Model->alias]['order_field'], $order);
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:34,代码来源:sequence.php


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