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


PHP AppModel::deleteAll方法代码示例

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


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

示例1: deleteAll

 public function deleteAll($conditions, $cascade = true, $callbacks = false)
 {
     $x = $this->find("all", array("contain" => false, "fields" => array('image'), "conditions" => $conditions));
     foreach ($x as $v) {
         $pth = ltrim($v[$this->alias]['image'], "https://www.pickmeals.com/");
         unlink(str_replace("-0-", "-1-", $pth));
         unlink(str_replace("-0-", "-2-", $pth));
         unlink($pth);
     }
     parent::deleteAll($conditions, $cascade, $callbacks);
 }
开发者ID:ashutoshdev,项目名称:pickmeals-web,代码行数:11,代码来源:Combination.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

示例3: beforeDelete

 /**
  * Before delete method. Called before all deletes
  *
  * Will delete the current node and all children using the deleteAll method and sync the table
  *
  * @param AppModel $model
  * @return boolean true to continue, false to abort the delete
  */
 function beforeDelete(&$model)
 {
     extract($this->settings[$model->alias]);
     if (!$enabled) {
         return true;
     }
     list($name, $data) = array($model->alias, $model->read());
     $data = $data[$name];
     if (!$data[$right] || !$data[$left]) {
         return true;
     }
     $diff = $data[$right] - $data[$left] + 1;
     if ($diff > 2) {
         $constraint = $scope . ' AND ' . $model->escapeField($left) . ' BETWEEN ' . ($data[$left] + 1) . ' AND ' . ($data[$right] - 1);
         $model->deleteAll($constraint);
     }
     $this->__sync($model, $diff, '-', '> ' . $data[$right]);
     return true;
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:27,代码来源:tree.php

示例4: beforeDelete

 /**
  * Before delete method. Called before all deletes
  *
  * Will delete the current node and all children using the deleteAll method and sync the table
  *
  * @since 1.2
  * @param AppModel $model
  * @return boolean True to continue, false to abort the delete
  */
 function beforeDelete(&$model)
 {
     extract($this->settings[$model->name]);
     list($name, $data) = array($model->name, $model->read());
     $data = $data[$name];
     // If there is no tree data, skip.
     if (!$data[$right] || !$data[$left]) {
         return true;
     }
     $diff = $data[$right] - $data[$left] + 1;
     // Temporarily not an array
     $constraint = $scope . ' AND ' . $left . ' BETWEEN ' . $data[$left] . ' AND ' . $data[$right];
     $model->deleteAll($constraint);
     $this->__sync($model, $diff, '-', '> ' . $data[$right], $scope);
 }
开发者ID:paulToro,项目名称:webrocket,代码行数:24,代码来源:tree.php

示例5: deleteAll

 function deleteAll($conditions, $cascade = true, $callbacks = true)
 {
     parent::deleteAll($conditions, $cascade, $callbacks);
 }
开发者ID:rcaravita,项目名称:jodeljodel,代码行数:4,代码来源:tradutore_app_model.php


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