示例#1
0
                default:
                    fwrite(STDOUT, "Really? That's what you're going with? Not even going to try for the options huh?\n");
            }
        }
        break;
    case 0:
        fwrite(STDOUT, "Are you sure you want to Erase ALL data!? This action CANNOT be undone! [Y]es, [N]o ");
        $confirm = trim(strtolower(fgets(STDIN)), "\n");
        if ($confirm == "y" || $confirm == "yes") {
            //TODO get a list of tables and drop them!
            $db = new DataBaseSchema();
            $tables = $db->listTables();
            fwrite(STDOUT, "Once again you are about to empty the entire database erasing all data with it. This action is primarily for development servers or in case of database corruption. To continue please type 'yes'! ");
            $final_confirm = trim(fgets(STDIN), "\n");
            if ($final_confirm == "yes") {
                foreach ($tables as $table) {
                    $db->dropTable($table[0]);
                }
                fwrite(STDOUT, "Please verify that the database is now empty using the tools that came with your server software.\n");
                exit;
            } else {
                fwrite(STDOUT, "You typed '" . $final_confirm . "' this is not 'yes'. We will now exit without touching the database\n");
                exit;
            }
        } else {
            exit;
        }
        break;
    default:
        fwrite(STDOUT, "I'm sorry Jim, I can't let you do that!\n");
}