protected function _delete ($model = null, $id = '', $redirect = 'index', $attach = null, $pkField = 'id')
{
if ($attach) { //如果有附件要删除广告的图片
$data = $model->findAll($pkField . ' IN(:id)', array (':id' => $id ));
foreach ((array) $data as $row) {
foreach ((array) $attach as $value) {
if (! empty($row[$value])) {
@unlink($row[$value]);
}
}
}
}
$result = $model->deleteAll(array ('condition' => 'id IN(' . $id . ')' ));
//刷新缓存
self::_refreshCache($model);
$this->redirect($redirect);
}
复制代码 代码如下:
protected function _verify ($model = null, $type = 'verify', $id = '', $redirect = 'index', $cdField = 'status_is', $pkField = 'id')
{
$criteria = new CDbCriteria();
$criteria->condition = $pkField . ' IN(' . $id . ')';
$showStatus = $type == 'verify' ? 'Y' : 'N';
$result = $model->updateAll(array ($cdField => $showStatus ), $criteria);
//刷新缓存
self::_refreshCache($model);
$this->redirect($redirect);
}