예제 #1
0
} catch (Exception $e) {
    $messages = $e->getMessage();
    if (empty($messages) === false) {
        die(sprintf(HTML_LAYOUT, $self, $messages));
    }
}
try {
    $records = $db->read(SQL_SELECT_RECORDS_ALL);
    $total_rows = count($records);
    if ($total_rows > $rows) {
        $random_ids = random_records($records, $rows);
        $total_random_ids = count($random_ids);
        if ($total_random_ids > 0) {
            foreach ($random_ids as $index => $random_id) {
                $data = array(":" . KEY_RANDOM_ID => $random_id);
                $affected = $db->delete($data, SQL_DELETE_RECORD_BY_ID);
            }
        }
    } else {
        $total_random_ids = $total_rows;
        foreach ($records as $index => $record) {
            $data = array(":" . KEY_RANDOM_ID => $record[KEY_ID]);
            $affected = $db->delete($data, SQL_DELETE_RECORD_BY_ID);
        }
    }
} catch (Exception $e) {
    $messages .= $e->getMessage();
}
$content = sprintf(HTML_DELETE_HEADER, $total_random_ids);
$messages = $db->dump_messages() . $messages;
if (empty($messages) === false) {