$old_tables = @mysql_num_rows(mysql_list_tables($old_dbname, $oldconn));
     if (!$old_tables) {
         echo '<br><font color="red"><b> Tables do not exist in the Source Database</b></font>';
         $continue3 = 0;
     } else {
         $migration_log .= '<br> Tables exist in the Database';
         $migrationlog->debug("Tables exist. continue3 = 1");
         $continue3 = 1;
     }
 }
 //$continue1 -- Database server can be connected
 //$continue2 -- Database exists in the server
 //$continue3 -- Tables are exist in the database
 if ($continue1 == 1 && $continue2 == 1 && $continue3 == 1) {
     $conn = new PearDatabase("mysql", $old_host_name . ":" . $old_mysql_port, $old_dbname, $old_mysql_username, $old_mysql_password);
     $conn->connect();
     $migrationlog->debug("MICKIE ==> Option = Alter DB details. From the given DB details we will migrate.");
     @session_unregister('migration_log');
     $_SESSION['migration_log'] = $migration_log;
     if ($conn) {
         $migrationlog->debug("Database object created. Going to create Migration object");
         $obj = new Migration('', $conn);
         $obj->setOldDatabaseParams($old_host_name, $old_mysql_port, $old_mysql_username, $old_mysql_password, $old_dbname);
         //$obj->migrate($same_databases,'dbsource');
         $obj->modifyDatabase($conn);
     } else {
         echo '<br><font color="red"><b> Cannot make a connection with the current database setup</b></font>';
         include "modules/Migration/MigrationStep1.php";
     }
 } else {
     echo '<br><font color="red"><b>ERROR!!!!!!Please check the input values, unable to proceed.</b></font>';
    function getLastInsertID($seqname = '')
    {
        if ($this->isPostgres()) {
            $result = pg_query("SELECT currval('" . $seqname . "_seq')");
            if ($result) {
                $row = pg_fetch_row($result);
                $last_insert_id = $row[0];
            }
        } else {
            $last_insert_id = $this->database->Insert_ID();
        }
        return $last_insert_id;
    }
    // Function to escape the special characters in database name based on database type.
    function escapeDbName($dbName = '')
    {
        if ($dbName == '') {
            $dbName = $this->dbName;
        }
        if ($this->isMySql()) {
            $dbName = "`{$dbName}`";
        }
        return $dbName;
    }
}
/* End of class */
if (empty($adb)) {
    $adb = new PearDatabase();
    $adb->connect();
}
//$adb->database->setFetchMode(ADODB_FETCH_NUM);
Exemple #3
0
function &getSingleDBInstance()
{
    static $db = false;
    if ($db === false) {
        global $log;
        $log->info("start create peardatabase");
        $db = new PearDatabase();
        //$adb->enableSQLlog = true; //log sql
        $db->connect();
        if ($db->isMssql()) {
            $db->database->SetFetchMode(ADODB_FETCH_ASSOC);
        }
        $log->info("end create peardatabase");
    }
    return $db;
}