/** * 删除所有的action操作 * 写着玩的,不可随意执行,会把所有的operation删掉,并且删除这么operation和用户、角色之间的所有关系 * 但是也可以随便执行,因为AR模式在这里执行不了,提供个思路,哈哈。 */ public function clearOpers() { $criteria = new CDbCriteria(); $criteria->condition = "type = 0"; $actions = AuthItem::model()->findAll($criteria); foreach ($actions as $key => $action) { $criteria_child = new CDbCriteria(); $criteria_child->condition = "child = '{$action->name}'"; $flag = ItemChildren::model()->deleteAll($criteria_child); if ($flag > 0) { if ($action->delete()) { echo "{$action->name} delete success\n"; } else { echo "{$action->name} delete failed\n"; } } } }
protected function afterDelete() { parent::afterDelete(); Assignments::model()->deleteAll("itemname='" . $this->name . "'"); ItemChildren::model()->deleteAll("parent='" . $this->name . "'"); ItemChildren::model()->deleteAll("child='" . $this->name . "'"); }