function dump_all($data = false)
{
    global $db_name;
    ob_cleanup();
    define('DEBUG_CONSOLE_HIDE', 1);
    set_time_limit(0);
    $tables = list_tables();
    $table_filter = get('table_filter');
    $tables = table_filter($tables, $table_filter);
    header("Cache-control: private");
    header("Content-type: application/octet-stream");
    header('Content-Disposition: attachment; filename=' . date('Ymd') . '_' . $db_name . '.sql');
    foreach ($tables as $key => $table) {
        table_structure($table);
        if ($data) {
            table_data($table);
        }
        flush();
    }
    exit;
}
Example #2
0
function dump_all($data = false)
{
    // @dump
    // @structure
    // @data
    GET("table_filter", "string");
    global $db_driver, $db_server, $db_name;
    ob_cleanup();
    define('DEBUG_CONSOLE_HIDE', 1);
    set_time_limit(0);
    $tables = list_tables();
    $table_filter = $_GET["table_filter"];
    $tables = table_filter($tables, $table_filter);
    header("Cache-control: private");
    header("Content-type: application/octet-stream");
    header('Content-Disposition: attachment; filename=' . $db_name . '.sql');
    echo "--\n";
    if ($data) {
        echo "-- Dump type: DATA & STRUCTURE\n";
    } else {
        echo "-- Dump type: STRUCTURE ONLY\n";
    }
    if ("sqlite" == $db_driver) {
        echo "-- Database file: {$db_server}\n";
    } else {
        echo "-- Database: {$db_name}\n";
    }
    $date = date("Y-m-d");
    echo "-- Exported on: {$date}\n";
    $version = DBKISS_VERSION;
    echo "-- Powered by: DBKiss (http://www.gosu.pl/dbkiss/)\n";
    echo "--\n\n";
    foreach ($tables as $key => $table) {
        echo "-- TABLE: \"{$table}\"\n\n";
        table_structure($table);
        if ($data) {
            echo "-- INSERTS for: \"{$table}\"\n\n";
            table_data($table);
        }
        flush();
    }
    unset($table);
    $views = list_tables(true);
    foreach ($views as $key => $view) {
        echo "-- VIEW: \"{$view}\"\n\n";
        table_structure($view, "view");
        flush();
    }
    echo "--\n";
    echo "-- END OF DUMP\n";
    echo "--\n";
    exit;
}