$(document).ready(function () {
    alert('RUNOOB');
});
function checkField() {
    $db = Typecho_Db::get();
    $prefix = $db->getPrefix();

    // Determine the database adapter
    $adapter = $db->getAdapterName();

    // Get the columns info depending on adapter
    if ($adapter === 'Pdo_Sqlite') {
        // SQLite syntax
        $postFields = $db->fetchAll($db->query('PRAGMA table_info(' . $prefix . 'contents)'));
        $columnNames = array_column($postFields, 'name');
    } else {
        // MySQL syntax
        $postFields = $db->fetchAll($db->query("SHOW COLUMNS FROM `" . $prefix . "contents`"));
        $columnNames = array_column($postFields, 'Field');
    }

    // If 'views' column does not exist, add it
    if (!in_array('views', $columnNames)) {
        $db->query('ALTER TABLE `' . $prefix . 'contents` ADD `views` INT(10) NOT NULL DEFAULT 0;');
    }

    // If 'agree' column does not exist, add it
    if (!in_array('agree', $columnNames)) {
        $db->query('ALTER TABLE `' . $prefix . 'contents` ADD `agree` INT(10) NOT NULL DEFAULT 0;');
    }
}
if ($db->getAdapterName() === 'Pdo_Sqlite') {
    $result = $db->query('PRAGMA table_info(typecho_contents)');
} else {
    // MySQL syntax to get columns info
    $result = $db->query("SHOW COLUMNS FROM `typecho_contents`");
}