public function postDeleteAction() { $id = $_POST['spending_id']; $spend = SpendingModel::model()->getRowFromPk($id); if ($spend) { if ($spend->delete()) { echo 1; } } return 1; }
public function duplicate($id) { DB::startTransaction(); $query = "insert into " . $this->tableName() . " (name, user_id, traffic_source_id, rotate, cloaker_id, type)"; $query .= "select concat(name,' copy') as name, user_id, traffic_source_id, rotate, cloaker_id, type from " . $this->tableName() . " "; $query .= "where campaign_id='" . DB::quote($id) . "'"; if (!DB::query($query)) { DB::rollback(); return false; } $new_id = DB::insertId(); if (!$new_id) { DB::rollback(); return false; } if (!CampaignOfferModel::model()->duplicate($id, $new_id)) { DB::rollback(); return false; } if (!CampaignLPModel::model()->duplicate($id, $new_id)) { DB::rollback(); return false; } if (!CampaignOptionModel::model()->duplicate($id, $new_id)) { DB::rollback(); return false; } if (!SpendingModel::model()->duplicate($id, $new_id)) { DB::rollback(); return false; } DB::commit(); return $new_id; }