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


PHP AppModel::unbindModel方法代码示例

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


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

示例1: unbindModelAll

 /**
  * Unbind the all model mapping
  */
 public function unbindModelAll()
 {
     $unbind = array();
     foreach ($this->belongsTo as $model => $info) {
         $unbind['belongsTo'][] = $model;
     }
     foreach ($this->hasOne as $model => $info) {
         $unbind['hasOne'][] = $model;
     }
     foreach ($this->hasMany as $model => $info) {
         $unbind['hasMany'][] = $model;
     }
     foreach ($this->hasAndBelongsToMany as $model => $info) {
         $unbind['hasAndBelongsToMany'][] = $model;
     }
     parent::unbindModel($unbind);
 }
开发者ID:trungjc,项目名称:collegeprospectnetwork,代码行数:20,代码来源:AdminAppModel.php

示例2: recover

 /**
  * Recover a corrupted tree
  *
  * The mode parameter is used to specify the source of info that is valid/correct. The opposite source of data
  * will be populated based upon that source of info. E.g. if the MPTT fields are corrupt or empty, with the $mode
  * 'parent' the values of the parent_id field will be used to populate the left and right fields. The missingParentAction
  * parameter only applies to "parent" mode and determines what to do if the parent field contains an id that is not present.
  *
  * @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB.
  * @param AppModel $Model Model instance
  * @param string $mode parent or tree
  * @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to
  * delete, or the id of the parent to set as the parent_id
  * @return boolean true on success, false on failure
  * @access public
  * @link http://book.cakephp.org/view/1628/Recover
  */
 function recover(&$Model, $mode = 'parent', $missingParentAction = null)
 {
     if (is_array($mode)) {
         extract(array_merge(array('mode' => 'parent'), $mode));
     }
     extract($this->settings[$Model->alias]);
     $Model->recursive = $recursive;
     if ($mode == 'parent') {
         $Model->bindModel(array('belongsTo' => array('VerifyParent' => array('className' => $Model->alias, 'foreignKey' => $parent, 'fields' => array($Model->primaryKey, $left, $right, $parent)))));
         $missingParents = $Model->find('list', array('recursive' => 0, 'conditions' => array($scope, array('NOT' => array($Model->escapeField($parent) => null), $Model->VerifyParent->escapeField() => null))));
         $Model->unbindModel(array('belongsTo' => array('VerifyParent')));
         if ($missingParents) {
             if ($missingParentAction == 'return') {
                 foreach ($missingParents as $id => $display) {
                     $this->errors[] = 'cannot find the parent for ' . $Model->alias . ' with id ' . $id . '(' . $display . ')';
                 }
                 return false;
             } elseif ($missingParentAction == 'delete') {
                 $Model->deleteAll(array($Model->primaryKey => array_flip($missingParents)));
             } else {
                 $Model->updateAll(array($parent => $missingParentAction), array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)));
             }
         }
         $count = 1;
         foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey), 'order' => $left)) as $array) {
             $Model->id = $array[$Model->alias][$Model->primaryKey];
             $lft = $count++;
             $rght = $count++;
             $Model->save(array($left => $lft, $right => $rght), array('callbacks' => false));
         }
         foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) {
             $Model->create();
             $Model->id = $array[$Model->alias][$Model->primaryKey];
             $this->_setParent($Model, $array[$Model->alias][$parent]);
         }
     } else {
         $db =& ConnectionManager::getDataSource($Model->useDbConfig);
         foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) {
             $path = $this->getpath($Model, $array[$Model->alias][$Model->primaryKey]);
             if ($path == null || count($path) < 2) {
                 $parentId = null;
             } else {
                 $parentId = $path[count($path) - 2][$Model->alias][$Model->primaryKey];
             }
             $Model->updateAll(array($parent => $db->value($parentId, $parent)), array($Model->escapeField() => $array[$Model->alias][$Model->primaryKey]));
         }
     }
     return true;
 }
开发者ID:ale3andro,项目名称:metathesi,代码行数:66,代码来源:tree.php


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