public function afterDelete() { parent::afterDelete(); // Find all instances of the gateway in profiles_gateways... $sql = "SELECT * \n\t\tFROM profiles_gateways\n\t\tWHERE gateway_id = ?i"; $result = self::$_msql->getAll($sql, $this->getPkValue()); // Delete instances and reorder the rank of profile gateways foreach ($result as $key => $value) { $model = new ProfileGateway(); $model->profile_id = $value['profile_id']; $model->method_id = $value['method_id']; $model->gateway_id = $value['gateway_id']; $rank = $model->getRank(); $model->delete(); $model->decreaseRanksByOne($rank); unset($model); } }
function deleteAction() { $id = AF::get($_POST, 'id', 0); $ids = explode('_', $id); $errors = FALSE; $model = new ProfileGateway(); if (!$model->loadByIds($ids[0], $ids[1], $ids[2])) { echoJsonError('Error occurred. Gateway not deleted'); } $rank = $model->getRank(); $model->delete(); $model->decreaseRanksByOne($rank); unset($model); Message::echoJsonRedirect("/lj3/profiles/update/id=" . $ids[0]); }