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


PHP Actions::delete方法代码示例

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


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

示例1: delete

 public function delete($id)
 {
     $db = new Db($this->subgridConfig, $this->statusVariables);
     $fields = $this->subgridConfig->fields();
     $curData = $db->fetchRow($id);
     foreach ($fields as $field) {
         $fieldObject = $this->subgridConfig->fieldObject($field);
         $fieldObject->beforeDelete($id, $curData);
     }
     $sql = "\n        DELETE\n            " . $this->subgridConfig->tableName() . "\n        FROM\n            " . $this->subgridConfig->tableName() . "\n            " . $db->joinQuery() . "\n        WHERE\n            " . $this->subgridConfig->tableName() . ".`" . $this->subgridConfig->idField() . "` = :id\n        ";
     $params = array('id' => $id);
     $callables = $this->subgridConfig->beforeDelete();
     if ($callables) {
         if (is_array($callables) && !is_callable($callables)) {
             foreach ($callables as $callable) {
                 call_user_func($callable, $params['id']);
             }
         } else {
             call_user_func($callables, $params['id']);
         }
     }
     ipDb()->execute($sql, $params);
     if ($this->subgridConfig->isMultilingual()) {
         $sql = "\n            DELETE\n\n            FROM\n                " . $this->subgridConfig->languageTableName() . "\n            WHERE\n                " . $this->subgridConfig->languageTableName() . ".`" . $this->subgridConfig->languageForeignKeyField() . "` = :id\n            ";
         ipDb()->execute($sql, $params);
     }
     $callables = $this->subgridConfig->afterDelete();
     if ($callables) {
         if (is_array($callables) && !is_callable($callables)) {
             foreach ($callables as $callable) {
                 call_user_func($callable, $params['id']);
             }
         } else {
             call_user_func($callables, $params['id']);
         }
     }
     //remove records in child grids
     foreach ($fields as $field) {
         $fieldObject = $this->subgridConfig->fieldObject($field);
         $fieldObject->afterDelete($id, $curData);
         if ($field['type'] == 'Grid') {
             $childStatusVariables = Status::genSubgridVariables($this->statusVariables, $field['gridId'], $id);
             $subActions = new Actions(new Config($field['config']), $childStatusVariables);
             $childConfig = new Config($field['config']);
             $db = new Db($childConfig, $childStatusVariables);
             $where = $db->buildSqlWhere();
             $sql = "\n                    SELECT\n                        `" . $childConfig->idField() . "`\n                    FROM\n                        " . $childConfig->tableName() . "\n                    WHERE\n                        {$where}\n                ";
             $idsToDelete = ipDb()->fetchColumn($sql);
             foreach ($idsToDelete as $idToDelete) {
                 $subActions->delete($idToDelete);
             }
         }
     }
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:54,代码来源:Actions.php

示例2: destroy

 /**
  * remove a record from the database
  *
  * @param $model_id the id of the record to remove
  **/
 public static function destroy($model_id)
 {
     Actions::delete(static::getTableName(), $model_id);
 }
开发者ID:andela-bkagia,项目名称:php-checkpoints,代码行数:9,代码来源:BaseModel.php


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