function delete_action($id) { $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD); $action = fetch_action($id); $statement = $connection->prepare("select count(*) from actions where active=1 and achievement_id!=0 and name=?"); $statement->bindValue(1, $action->name, PDO::PARAM_STR); $statement->execute(); if ((int) $statement->fetchColumn() == 1) { $statement = $connection->prepare("update actions set active=0 where achievement_id=0 and name=?"); $statement = $connection->bindValue(1, $action->name, PDO::PARAM_STR); $statement->execute(); } $statement = $connection->prepare("update actions set active=0 where id=?"); $statement->bindValue(1, $id, PDO::PARAM_INT); $statement->execute(); }