/**
  * Returns a single static instance of this object.
  *
  * @return MpmCommandLineWriter
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new MpmCommandLineWriter();
     }
     return self::$instance;
 }
Пример #2
0
 /**
  * Displays the help page for this controller.
  *
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  *
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php add');
     $obj->addText(' ');
     $obj->addText('This command is used to create a new migration script.  The script will be created and prepopulated with the up() and down() methods which you can then modify for the migration.');
     $obj->addText(' ');
     $obj->addText('Valid Example:');
     $obj->addText('./migrate.php add', 4);
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php status');
     $obj->addText(' ');
     $obj->addText('This command is used to display the current migration you are on and lists any pending migrations which would be performed if you migrated to the most recent version of the database.');
     $obj->addText(' ');
     $obj->addText('Valid Example:');
     $obj->addText('./migrate.php status', 4);
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  *
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  *
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php latest [--force]');
     $obj->addText(' ');
     $obj->addText('This command is used to migrate up to the most recent version.  No arguments are required.');
     $obj->addText(' ');
     $obj->addText('If the --force option is provided, then the script will automatically skip over any migrations which cause errors and continue migrating forward.');
     $obj->addText(' ');
     $obj->addText('Valid Examples:');
     $obj->addText('./migrate.php latest', 4);
     $obj->addText('./migrate.php latest --force', 4);
     $obj->write();
 }
Пример #5
0
 /**
  * Displays the help page for this controller.
  *
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  *
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php up <migration #> [--force|-f] [--dry-run|-p] [--dumpsql|-d]');
     $obj->addText(' ');
     $obj->addText('This command is used to migrate up to a newer version.  You can get a list of all of the migrations available by using the list command.');
     $obj->addText(' ');
     $obj->addText('You must specify a migration # (as provided by the list command)');
     $obj->addText(' ');
     $obj->addText('If the --force option is provided, then the script will automatically skip over any migrations which cause errors and continue migrating forward.');
     $obj->addText(' ');
     $obj->addText('Valid Examples:');
     $obj->addText('./migrate.php up 14', 4);
     $obj->addText('./migrate.php up 12 --force', 4);
     $obj->write();
 }
Пример #6
0
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php list [page] [per page]');
     $obj->addText(' ');
     $obj->addText('This command is used to display a list of all the migrations available.  Each migration is listed by number and timestamp.  You will need the migration number in order to perform an up or down migration.');
     $obj->addText(' ');
     $obj->addText('Since a project may have a large number of migrations, this command is paginated.  The page number is required.  If you do not enter it, the command will assume you want to see page 1.');
     $obj->addText(' ');
     $obj->addText('If you do not provide a per page argument, this command will default to 30 migrations per page.');
     $obj->addText(' ');
     $obj->addText('Valid Examples:');
     $obj->addText('./migrate.php list', 4);
     $obj->addText('./migrate.php list 2', 4);
     $obj->addText('./migrate.php list 1 15', 4);
     $obj->write();
 }
Пример #7
0
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php down [migration #] [--force]');
     $obj->addText(' ');
     $obj->addText('This command is used to migrate down to a previous version.  You can get a list of all of the migrations available by using the list command.');
     $obj->addText(' ');
     $obj->addText('You must specify a migration # (as provided by the list command)');
     $obj->addText(' ');
     $obj->addText('If you enter a migration number of 0 or -1, all migrations will be removed.');
     $obj->addText(' ');
     $obj->addText('If the --force option is provided, then the script will automatically skip over any migrations which cause errors and continue migrating backward.');
     $obj->addText(' ');
     $obj->addText('Valid Examples:');
     $obj->addText('./migrate.php down 14', 4);
     $obj->addText('./migrate.php down 12 --force', 4);
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('The Following Commands Are Available:');
     $obj->addText('add    - add a new migration', 4);
     $obj->addText('build  - builds the database', 4);
     $obj->addText('down   - roll down to a previous migration', 4);
     $obj->addText('help   - get more specific help about individual commands', 4);
     $obj->addText('init   - initialize the migrations', 4);
     $obj->addText('latest - roll up to the latest migration', 4);
     $obj->addText('list   - list all migrations', 4);
     $obj->addText('run    - runs a single migration', 4);
     $obj->addText('status - show the current migration', 4);
     $obj->addText('up     - roll up to a future migration', 4);
     $obj->addText(' ');
     $obj->addText('For specific help for an individual command, type:');
     $obj->addText('./migrate.php help [command]', 4);
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php init');
     $obj->addText(' ');
     $obj->addText('This command is used to initialize the migration system for use with your particular deployment.  After you have modified the /config/db.php configuration file appropriately, you should run this command to setup the initial tracking schema and add your username to the migraiton archive.');
     $obj->addText(' ');
     $obj->addText('Example:');
     $obj->addText('./migrate.php init jdoe', 4);
     $obj->write();
 }
Пример #10
0
 /**
  * Checks to make sure everything is in place to be able to use the migrations tool.
  *
  * @uses MpmDbHelper::getMethod()
  * @uses MpmDbHelper::getPdoObj()
  * @uses MpmDbHelper::getMysqliObj()
  * @uses MpmDbHelper::getMethod()
  * @uses MpmDbHelper::checkForDbTable()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * @uses MPM_METHOD_PDO
  * @uses MPM_METHOD_MYSQLI
  *
  * @return void     
  */
 public static function test()
 {
     $problems = array();
     if (!file_exists(MPM_PATH . '/config/db_config.php')) {
         $problems[] = 'You have not yet run the init command.  You must run this command before you can use any other commands.';
     } else {
         switch (MpmDbHelper::getMethod()) {
             case MPM_METHOD_PDO:
                 if (!class_exists('PDO')) {
                     $problems[] = 'It does not appear that the PDO extension is installed.';
                 }
                 $drivers = PDO::getAvailableDrivers();
                 if (!in_array('mysql', $drivers)) {
                     $problems[] = 'It appears that the mysql driver for PDO is not installed.';
                 }
                 if (count($problems) == 0) {
                     try {
                         $pdo = MpmDbHelper::getPdoObj();
                     } catch (Exception $e) {
                         $problems[] = 'Unable to connect to the database: ' . $e->getMessage();
                     }
                 }
                 break;
             case MPM_METHOD_MYSQLI:
                 if (!class_exists('mysqli')) {
                     $problems[] = "It does not appear that the mysqli extension is installed.";
                 }
                 if (count($problems) == 0) {
                     try {
                         $mysqli = MpmDbHelper::getMysqliObj();
                     } catch (Exception $e) {
                         $problems[] = "Unable to connect to the database: " . $e->getMessage();
                     }
                 }
                 break;
         }
         if (!MpmDbHelper::checkForDbTable()) {
             $problems[] = 'Migrations table not found in your database.  Re-run the init command.';
         }
         if (count($problems) > 0) {
             $obj = MpmCommandLineWriter::getInstance();
             $obj->addText("It appears there are some problems:");
             $obj->addText("\n");
             foreach ($problems as $problem) {
                 $obj->addText($problem, 4);
                 $obj->addText("\n");
             }
             $obj->write();
             exit;
         }
     }
 }
 /**
  * @static
  * @param object $obj		a simple object with migration information (from a migration list)
  * @param string $method
  * @param array $options
  * @return mixed
  */
 public static function runMigration(&$obj, $method = 'up', array $options = array())
 {
     // if true, exceptions will not cause the script to exit
     $forced = isset($options['forced']) ? $options['forced'] : false;
     // if true, only echo back the SQL to be run
     $dryrun = isset($options['dryrun']) ? $options['dryrun'] : false;
     $db_config = MpmDbHelper::get_db_config();
     $migrations_table = $db_config->migrations_table;
     $filename = MpmStringHelper::getFilenameFromTimestamp($obj->timestamp);
     $classname = 'Migration_' . str_replace('.php', '', $filename);
     // make sure the file exists; if it doesn't, skip it but display a message
     $migration_file = MpmListHelper::get_migration_file(MPM_DB_PATH . $filename);
     if (!$migration_file) {
         echo "\n\tMigration " . $obj->timestamp . ' (ID ' . $obj->id . ') skipped - file missing.';
         return;
     }
     // file exists -- run the migration
     require_once $migration_file;
     $migration = new $classname();
     $msg = "# Performing " . strtoupper($method) . " migration " . $obj->timestamp . ' (ID ' . $obj->id . ')';
     if (!empty($migration->info)) {
         $msg .= "\n# {$migration->info}";
     }
     echo "\n" . $msg . " ... ";
     MpmSqlLogger::log_to_file("\n" . $msg . "\n");
     if ($migration instanceof MpmMigration) {
         $dbObj = MpmDbHelper::getPdoObj();
     } else {
         $dbObj = MpmDbHelper::getMysqliObj();
     }
     if ($dryrun) {
         $dbObj->dryrun = true;
     }
     $dbObj->beginTransaction();
     if ($method == 'down') {
         $active = 0;
     } else {
         $active = 1;
     }
     try {
         $migration->{$method}($dbObj);
         $sql = "UPDATE `{$migrations_table}` SET `active` = '{$active}' WHERE `id` = {$obj->id}";
         $dbObj->internal_exec($sql);
     } catch (Exception $e) {
         $dbObj->rollback();
         echo "failed!";
         echo "\n";
         $clw = MpmCommandLineWriter::getInstance();
         $clw->writeLine($e->getMessage(), 12);
         if (!$forced) {
             echo "\n\n";
             // Return with non-0 error code to notify external caller to stop the deployment
             exit(1);
         } else {
             return;
         }
     }
     $dbObj->commit();
     echo "done.";
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php propose');
     $obj->addText(' ');
     $obj->addText('This command is used check the suggested migration path, especially after a merge or checkout.');
     $obj->addText(' ');
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php build [--force|add]');
     $obj->addText(' ');
     $obj->addText('This command is used to build the database.  If a schema.php file is found in the migrations directory, the MpmSchema::Build() method will be called.  Then, all migrations will be run against the database.');
     $obj->addText(' ');
     $obj->addText('Use the "add" argument to create an empty stub for the schema.php file.  You can then add your own query statements.');
     $obj->addText(' ');
     $obj->addText('If you use the "--force" argument instead of the "add" argument, you will not be prompted to confirm the action (good for scripting a build process).');
     $obj->addText(' ');
     $obj->addText('WARNING: THIS IS A DESTRUCTIVE ACTION!!  BEFORE THE DATABASE IS BUILT, ALL TABLES CURRENTLY IN THE DATABASE ARE REMOVED!');
     $obj->addText(' ');
     $obj->addText('Valid Example:');
     $obj->addText('./migrate.php add', 4);
     $obj->write();
 }
Пример #14
0
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php run [method] [migration #]');
     $obj->addText(' ');
     $obj->addText('This command is used to run a single migration.');
     $obj->addText(' ');
     $obj->addText('You must specify a method to run (either up or down) and a migration # (as provided by the list command)');
     $obj->addText(' ');
     $obj->addText('Valid Examples:');
     $obj->addText('./migrate.php run up 13', 4);
     $obj->addText('./migrate.php run down 12', 4);
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php add [additional_file_name_notes]');
     $obj->addText(' ');
     $obj->addText('This command is used to create a new migration script.  The script will be created and prepopulated with the up() and down() methods which you can then modify for the migration.');
     $obj->addText(' ');
     $obj->addText('You may optionally include a word or phrase that will be added to the end of the filename when it\'s created.');
     $obj->addText(' ');
     $obj->addText('Valid Example:');
     $obj->addText('./migrate.php add', 4);
     $obj->addText('./migrate.php add create_fulltext_indices', 4);
     $obj->write();
 }
 /**
  * Displays the help page for this controller.
  * 
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  * 
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php migrate [--force]');
     $obj->addText(' ');
     $obj->addText('This command is used to migrate down to the nearest shared patch, then back up to the latest.');
     $obj->addText('It is designed to be most useful when checking out branched code');
     $obj->addText('If the --force option is provided, then the script will automatically skip over any migrations which cause errors and continue migrating backward.');
     $obj->write();
 }
 /**
  * Performs a single migration.
  *
  * @uses MpmStringHelper::getFilenameFromTimestamp()
  * @uses MpmDbHelper::getPdoObj()
  * @uses MpmDbHelper::getMysqliObj()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::writeLine()
  * @uses MPM_DB_PATH
  *
  * @param object  $obj        		    a simple object with migration information (from a migration list)
  * @param int    &$total_migrations_run a running total of migrations run
  * @param bool    $forced               if true, exceptions will not cause the script to exit
  *
  * @return void
  */
 public static function runMigration(&$obj, $method = 'up', $forced = false)
 {
     $file_timestamp = MpmStringHelper::getFilenameFromTimestamp($obj->timestamp);
     if ($method == 'up') {
         $classname = 'Migration_' . $file_timestamp;
         // make sure the file exists; if it doesn't, skip it but display a message
         $files = glob(MPM_DB_PATH . $file_timestamp . '*.php');
         if (empty($files)) {
             echo "\n\tMigration " . $obj->timestamp . ' (ID ' . $obj->id . ') skipped - file missing.';
             return;
         }
         if (count($files) > 1) {
             echo "\n\tError: Duplicate migration timestamp found! " . $obj->timestamp . ' (ID ' . $obj->id . ')';
             exit;
         }
         $filename = $files[0];
         // file exists -- run the migration
         echo "\n\tPerforming " . strtoupper($method) . " migration " . $obj->timestamp . ' (ID ' . $obj->id . ')... ';
         require_once $filename;
         $migration = new $classname();
     } else {
         //migrate down via stored database objects
         //fetch object from database
         //unserialize
         eval('?>' . $obj->objectstore . '<?');
         $down_migration = 'Migration_objectstore_' . $file_timestamp;
         $migration = new $down_migration();
         if (!$migration) {
             echo "failed!";
             $clw = MpmCommandLineWriter::getInstance();
             $clw->writeLine("Migration " . $obj->timestamp . ' (ID ' . $obj->id . ') - Object missing or broken', 12);
             if (!$forced) {
                 echo "\n\n";
                 exit;
             } else {
                 return;
             }
         }
         echo "\n\tPerforming " . strtoupper($method) . " migration " . $obj->timestamp . ' (ID ' . $obj->id . ')... ';
     }
     if ($migration instanceof MpmMigration) {
         $dbObj = MpmDbHelper::getPdoObj();
     } else {
         $dbObj = MpmDbHelper::getMysqliObj();
     }
     $dbObj->beginTransaction();
     if ($method == 'down') {
         $active = 0;
     } else {
         $active = 1;
     }
     try {
         $migration->{$method}($dbObj);
         if ($method == 'up') {
             //fetch object, store in database
             $string = file_get_contents($filename);
             $string = preg_replace('/(class Migration_)(\\d{4}(?:_\\d{2}){5})/', '$1objectstore_$2', $string, 1);
             $query_serial = sprintf(', objectstore="%s" ', $dbObj->real_escape_string($string));
             $sql = "UPDATE `mpm_migrations` SET `active` = '{$active}' {$query_serial} WHERE `id` = {$obj->id}";
         } else {
             //delete from database.
             //Old and new items may need to take same ID space in DB
             $sql = "DELETE FROM `mpm_migrations` WHERE `id` = {$obj->id}";
         }
         $dbObj->exec($sql);
     } catch (Exception $e) {
         $dbObj->rollback();
         echo "failed!";
         echo "\n";
         $clw = MpmCommandLineWriter::getInstance();
         $clw->writeLine($e->getMessage(), 12);
         if (!$forced) {
             echo "\n\n";
             exit;
         } else {
             return;
         }
     }
     $dbObj->commit();
     echo "done.";
 }
Пример #18
0
// fix date issues
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set("UTC");
}
/**
 * Define the full path to this file.
 */
if (!defined('MPM_PATH')) {
    define('MPM_PATH', dirname(__FILE__));
}
/**
 * Version Number - for reference
 */
if (!defined('MPM_VERSION')) {
    define('MPM_VERSION', '2.2.0-luxbet');
}
/**
 * Include the init script.
 */
require_once MPM_PATH . '/lib/init.php';
// get the proper controller, do the action, and exit the script
try {
    $obj = MpmControllerFactory::getInstance($argv);
    $obj->doAction(true);
} catch (MpmClassUndefinedException $ex) {
    // exit gracefully when wrong action is called like './migrate.php -h'
    $obj = MpmCommandLineWriter::getInstance();
    $obj->addText('Invalid action. Please try "./migrate.php help"');
    $obj->addText($ex->getMessage());
    $obj->write();
}
 /**
  * Displays the help page for this controller.
  *
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::addText()
  * @uses MpmCommandLineWriter::write()
  *
  * @return void
  */
 public function displayHelp()
 {
     $obj = MpmCommandLineWriter::getInstance();
     $obj->addText('./migrate.php build [--force|add]');
     $obj->addText(' ');
     $obj->addText('This command is used to build the database.  If a schema.php file is found in the migrations directory, the MpmSchema::Build() method will be called.  Then, all migrations will be run against the database.');
     $obj->addText(' ');
     $obj->addText('Use the "add" argument to create an empty stub for the schema.php file.  You can then add your own query statements.  This will also add a filed called test_data.php.  You can add queries to this file to insert test data after a build.');
     $obj->addText(' ');
     $obj->addText('Use the "with_data" argument to run the test_data.php file after the database has been rebuilt.  This allows you to automatically insert fresh new test data into the system.');
     $obj->addText(' ');
     $obj->addText('If you use the "--force" argument instead of the "add" argument, you will not be prompted to confirm the action (good for scripting a build process).');
     $obj->addText(' ');
     $obj->addText('WARNING: THIS IS A DESTRUCTIVE ACTION!!  BEFORE THE DATABASE IS BUILT, ALL TABLES CURRENTLY IN THE DATABASE ARE REMOVED!');
     $obj->addText(' ');
     $obj->addText('Valid Examples:');
     $obj->addText('./migrate.php build add', 4);
     $obj->addText('./migrate.php build with_data', 4);
     $obj->addText('./migrate.php build with_data [--force|-f] [--dry-run|-p]', 4);
     $obj->write();
 }
 /**
  * Performs a single migration.
  *
  * @uses MpmStringHelper::getFilenameFromTimestamp()
  * @uses MpmDbHelper::getPdoObj()
  * @uses MpmDbHelper::getMysqliObj()
  * @uses MpmCommandLineWriter::getInstance()
  * @uses MpmCommandLineWriter::writeLine()
  * @uses MPM_DB_PATH
  *
  * @param object  $obj        		    a simple object with migration information (from a migration list)
  * @param int    &$total_migrations_run a running total of migrations run
  * @param bool    $forced               if true, exceptions will not cause the script to exit
  *
  * @return void
  */
 public static function runMigration(&$obj, $method = 'up', $forced = false)
 {
     $filename = MpmStringHelper::getFilenameFromTimestamp($obj->timestamp);
     $classname = 'Migration_' . str_replace('.php', '', $filename);
     // make sure the file exists; if it doesn't, skip it but display a message
     if (!file_exists(MPM_DB_PATH . $filename)) {
         echo "\n\tMigration " . $obj->timestamp . ' (ID ' . $obj->id . ') skipped - file missing.';
         return;
     }
     // file exists -- run the migration
     echo "\n\tPerforming " . strtoupper($method) . " migration " . $obj->timestamp . ' (ID ' . $obj->id . ')... ';
     require_once MPM_DB_PATH . $filename;
     $migration = new $classname();
     if ($migration instanceof MpmMigration) {
         $dbObj = MpmDbHelper::getPdoObj();
     } else {
         $dbObj = MpmDbHelper::getMysqliObj();
     }
     $dbObj->beginTransaction();
     if ($method == 'down') {
         $active = 0;
     } else {
         $active = 1;
     }
     try {
         $migration->{$method}($dbObj);
         $sql = "UPDATE `mpm_migrations` SET `active` = '{$active}' WHERE `id` = {$obj->id}";
         $dbObj->exec($sql);
     } catch (Exception $e) {
         $dbObj->rollback();
         echo "failed!";
         echo "\n";
         $clw = MpmCommandLineWriter::getInstance();
         $clw->writeLine($e->getMessage(), 12);
         if (!$forced) {
             echo "\n\n";
             exit;
         } else {
             return;
         }
     }
     $dbObj->commit();
     echo "done.";
 }