本文整理汇总了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);
}
}
}
}
示例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);
}