Example #1
0
function updateDatabaseProperly()
{
    $var = parse_sql_data();
    foreach ($var as $table => $content) {
        $__db = new Sqlite(null, $table);
        $res = $__db->getColumnTypes();
        if ($res) {
            //dprint("Table $table Already exists\n");
            updateTableProperly($__db, $table, $res, $content);
        } else {
            dprint("Adding table {$table} \n");
            create_table($__db, $table, $var[$table]);
        }
    }
}
Example #2
0
File: lib.php Project: zseand/kloxo
function dropcolumn($tbl_name, $column)
{
    dprint("Dropping Column...............\n");
    $db = new Sqlite($tbl_name);
    $columnold = $db->getColumnTypes();
    $oldcolumns = array_keys($columnold);
    foreach ($oldcolumns as $key => $l) {
        $t = array_search(trim($l), $column);
        if (!empty($t)) {
            dprint("value {$oldcolumns[$key]} has deleted\n");
            unset($oldcolumns[$key]);
        } else {
            $newcollist[] = $l;
        }
    }
    $newfields = implode(",", $newcollist);
    dprint("New fields are \n");
    $query = "select " . $newfields . " from" . " " . $tbl_name;
    $res = $db->rawQuery($query);
    changeValues($res, $tbl_name, $db, $newfields);
}