예제 #1
0
 function connect($host, $db, $user, $password, $persistent = false)
 {
     parent::connect($host, $db, $user, $password, $persistent);
     $args = array();
     $args['Type'] = $this->_dbType;
     $args['User'] = $user;
     $args['Password'] = $password;
     $args['Host'] = $host;
     $args['Persistent'] = $persistent ? 1 : 0;
     $error = MetabaseSetupDatabase($args, $this->db);
     if ($error != null) {
         $this->error = $error;
         return false;
     } else {
         MetabaseSetDatabase($this->db, $db);
         return true;
     }
 }
예제 #2
0
 function GetDefinitionFromDatabase(&$arguments)
 {
     if (strcmp($error = $this->SetupDatabase($arguments), "")) {
         return $this->error = "Could not setup database: {$error}";
     }
     MetabaseSetDatabase($this->database, $database = MetabaseSetDatabase($this->database, ""));
     if (strlen($database) == 0) {
         return "it was not specified a valid database name";
     }
     $this->database_definition = array("name" => $database, "create" => 1, "TABLES" => array());
     if (!MetabaseListTables($this->database, $tables)) {
         return MetabaseError($this->database);
     }
     for ($table = 0; $table < count($tables); $table++) {
         $table_name = $tables[$table];
         if (!MetabaseListTableFields($this->database, $table_name, $fields)) {
             return MetabaseError($this->database);
         }
         $this->database_definition["TABLES"][$table_name] = array("FIELDS" => array());
         for ($field = 0; $field < count($fields); $field++) {
             $field_name = $fields[$field];
             if (!MetabaseGetTableFieldDefinition($this->database, $table_name, $field_name, $definition)) {
                 return MetabaseError($this->database);
             }
             $this->database_definition["TABLES"][$table_name]["FIELDS"][$field_name] = $definition[0];
         }
         if (!MetabaseListTableIndexes($this->database, $table_name, $indexes)) {
             return MetabaseError($this->database);
         }
         if (count($indexes)) {
             $this->database_definition["TABLES"][$table_name]["INDEXES"] = array();
             for ($index = 0; $index < count($indexes); $index++) {
                 $index_name = $indexes[$index];
                 if (!MetabaseGetTableIndexDefinition($this->database, $table_name, $index_name, $definition)) {
                     return MetabaseError($this->database);
                 }
                 $this->database_definition["TABLES"][$table_name]["INDEXES"][$index_name] = $definition;
             }
         }
     }
     if (!MetabaseListSequences($this->database, $sequences)) {
         return MetabaseError($this->database);
     }
     for ($sequence = 0; $sequence < count($sequences); $sequence++) {
         $sequence_name = $sequences[$sequence];
         if (!MetabaseGetSequenceDefinition($this->database, $sequence_name, $definition)) {
             return MetabaseError($this->database);
         }
         $this->database_definition["SEQUENCES"][$sequence_name] = $definition;
     }
     return "";
 }
예제 #3
0
    // end for
    // add any rest to the returned array
    if (!empty($sql) && ereg('[^[:space:]]+', $sql)) {
        $ret[] = $sql;
    }
    return true;
}
// end of the 'PMA_splitSqlFile()' function
$smarty->assign("tpl_title", "Datenbank sichern/wiederherstellen");
$smarty->assign('tpl_nav', 'settings');
$smarty->assign('tpl_subnav', 'backup');
$smarty->assign('tpl_db', $request->GetVar('schema', 'session') . '_bar');
if ($request->GetVar('frm_schema', 'post') !== $request->undefined) {
    $file = $request->GetVar('frm_file', 'file');
    $schema = $request->GetVar('frm_schema', 'post');
    MetabaseSetDatabase($gDatabase, $schema);
    $filename = $HTTP_POST_FILES['frm_file']['tmp_name'];
    if (file_exists($filename)) {
        $sql = file_get_contents($filename);
        $auto_commit = false;
        $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
        $query = "SET FOREIGN_KEY_CHECKS = 0";
        $result = MetabaseQuery($gDatabase, $query);
        if (!$result) {
            $success = MetabaseRollbackTransaction($gDatabase);
            $errorhandler->display('SQL', 'database', $query);
        }
        $success = splitSqlFile($queries, $sql);
        for ($i = 0; $i < count($queries); ++$i) {
            if (substr($queries[$i], 0, 3) == "USE") {
                $query = "USE {$schema}";
예제 #4
0
$manager = new metabase_manager_class();
$success = $manager->UpdateDatabase($input_file, $input_file . ".before", $driver_arguments, $database_variables);
$debug_output = "";
if (count($manager->warnings) > 0) {
    $debug_output .= "WARNING:{$eol}" . implode($manager->warnings, "!{$eol}") . $eol;
}
if ($manager->database && isset($driver_arguments["CaptureDebug"])) {
    $debug_output .= MetabaseDebugOutput($manager->database);
}
$passed = $failed = 0;
if ($success) {
    if (!strcmp($error = MetabaseSetupDatabase($driver_arguments, $database), "")) {
        if (isset($driver_arguments["CaptureDebug"])) {
            MetabaseCaptureDebugOutput($database, 1);
        }
        MetabaseSetDatabase($database, $database_variables["name"]);
        if (isset($tests["storage"]) && $success) {
            $test = "storage";
            echo "Testing typed field storage and retrieval ... ";
            flush();
            $pass = 1;
            if (!MetabaseQuery($database, "DELETE FROM users")) {
                $success = 0;
            } else {
                $row = 1234;
                $data = array();
                $data["user_name"] = "user_{$row}";
                $data["user_password"] = "******";
                $data["subscribed"] = $row % 2;
                $data["user_id"] = $row;
                $data["quota"] = strval($row / 100);
예제 #5
0
function setHotelDB()
{
    global $errorhandler, $gDatasource, $gDatabase, $request;
    global $tbl_timetracker;
    $hoteltable = $request->GetVar('schema', 'session');
    $error = MetabaseSetupDatabase($gDatasource, &$gDatabase);
    if ($error != '') {
        $errorhandler->display('SQL', 'default.inc.php', $error);
        die;
    } else {
        // select database
        MetabaseSetDatabase($gDatabase, $hoteltable);
    }
    // global variables for DB fields
    $tbl_timetracker = $hoteltable . '.zvs_timetracker';
}
예제 #6
0
function setHotelDB()
{
    global $errorhandler, $gDatasource, $gDatabase, $request;
    global $tbl_guest, $tbl_address, $tbl_guest_address, $tbl_gast_begleit, $tbl_begleit, $tbl_guestcat, $tbl_guest_guestcat, $tbl_room, $tbl_roomcat, $tbl_bookingcat, $tbl_booking, $tbl_booking_detail, $tbl_booking_detail_guest, $tbl_season, $tbl_price, $tbl_receipt, $tbl_receipt_item, $tbl_article, $tbl_roomcat_article, $tbl_account, $tbl_paycat, $tbl_price2, $tbl_receiptnumber, $tbl_receipt_booking, $tbl_draftreceipt_booking, $tbl_draftreceipt, $tbl_draftreceipt_item, $tbl_timetracker;
    $hoteltable = $request->GetVar('schema', 'session');
    $error = MetabaseSetupDatabase($gDatasource, &$gDatabase);
    if ($error != '') {
        $errorhandler->display('SQL', 'default.inc.php', $error);
        die;
    } else {
        // select database
        MetabaseSetDatabase($gDatabase, $hoteltable);
    }
    // global variables for DB fields
    $tbl_guest = $hoteltable . '.zvs_guest';
    $tbl_address = $hoteltable . '.zvs_address';
    $tbl_guest_address = $hoteltable . '.zvs_guest_address';
    $tbl_gast_begleit = $hoteltable . '.zvs_guest_escort';
    $tbl_begleit = $hoteltable . '.zvs_escort';
    $tbl_guestcat = $hoteltable . '.zvs_guestcat';
    $tbl_guest_guestcat = $hoteltable . '.zvs_guest_guestcat';
    $tbl_room = $hoteltable . '.zvs_room';
    $tbl_roomcat = $hoteltable . '.zvs_roomcat';
    $tbl_bookingcat = $hoteltable . '.zvs_bookingcat';
    $tbl_booking = $hoteltable . '.zvs_booking';
    $tbl_booking_detail = $hoteltable . '.zvs_booking_detail';
    $tbl_booking_detail_guest = $hoteltable . '.zvs_booking_detail_guest';
    $tbl_season = $hoteltable . '.zvs_season';
    $tbl_price = $hoteltable . '.zvs_price';
    $tbl_receipt = $hoteltable . '.zvs_receipt';
    $tbl_receipt_item = $hoteltable . '.zvs_receipt_item';
    $tbl_article = $hoteltable . '.zvs_article';
    $tbl_roomcat_article = $hoteltable . '.zvs_roomcat_article';
    $tbl_account = $hoteltable . '.zvs_account';
    $tbl_paycat = $hoteltable . '.zvs_paycat';
    $tbl_price2 = $hoteltable . '.zvs_price2';
    $tbl_receiptnumber = $hoteltable . '.zvs_receiptnumber';
    $tbl_receipt_booking = $hoteltable . '.zvs_receipt_booking';
    $tbl_draftreceipt_booking = $hoteltable . '.zvs_draftreceipt_booking';
    $tbl_draftreceipt = $hoteltable . '.zvs_draftreceipt';
    $tbl_draftreceipt_item = $hoteltable . '.zvs_draftreceipt_item';
    $tbl_timetracker = $hoteltable . '.zvs_timetracker';
}
예제 #7
0
function setZVSHotelDB()
{
    global $errorhandler, $gZVSDatabase, $request;
    global $tbl_zvs_bookingcat, $tbl_zvs_guest, $tbl_zvs_booking, $tbl_zvs_booking_detail;
    global $zvsmysqlhost, $zvsmysqlpassword, $zvsmysqluser, $metabasepath;
    $hoteltable = $request->GetVar('schema', 'session');
    $gZVSDatasource = array('Type' => 'mysql', 'Host' => $zvsmysqlhost, 'User' => $zvsmysqluser, 'Password' => $zvsmysqlpassword, 'IncludePath' => $metabasepath, 'Persistent' => true, 'Options' => array('UseTransactions' => 1, 'DefaultTableType' => "INNODB"));
    $error = MetabaseSetupDatabase($gZVSDatasource, &$gZVSDatabase);
    if ($error != '') {
        $errorhandler->display('SQL', 'default.inc.php', $error);
        die;
    } else {
        // select database
        MetabaseSetDatabase($gZVSDatabase, $hoteltable);
    }
    // global variables for DB fields
    $tbl_zvs_bookingcat = $hoteltable . '.zvs_bookingcat';
    $tbl_zvs_guest = $hoteltable . '.zvs_guest';
    $tbl_zvs_booking = $hoteltable . '.zvs_booking';
    $tbl_zvs_booking_detail = $hoteltable . '.zvs_booking_detail';
}