예제 #1
0
function MetabaseShutdownTransactions()
{
    global $metabase_databases;
    for (Reset($metabase_databases), $database = 0; $database < count($metabase_databases); Next($metabase_databases), $database++) {
        $metabase_database = Key($metabase_databases);
        if ($metabase_databases[$metabase_database]->in_transaction && MetabaseRollbackTransaction($metabase_database)) {
            MetabaseAutoCommitTransactions($metabase_database, 1);
        }
    }
}
예제 #2
0
 /**
  * Article::saveupdatePeriod
  * 
  * Save period as new or update existing one
  * 
  * @access public 
  * @since 2004-12-13
  * @author Christian Ehret <*****@*****.**> 
  */
 function saveupdatePeriod()
 {
     global $gDatabase, $request, $tbl_period, $tbl_bararticle, $errorhandler;
     $periodid = $request->GetVar('frm_theperiodid', 'post');
     $active = false;
     $auto_commit = false;
     $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
     if ($request->GetVar('frm_periodact', 'post') == 'true') {
         $active = true;
         $query = sprintf("UPDATE {$tbl_period} SET \n\t\t\t\t\t\t\t active = %s,\n\t\t\t\t\t\t\t updated_date = NOW(), \n\t\t\t\t\t\t\t fk_updated_user_id = %s ", MetabaseGetBooleanFieldValue($gDatabase, false), $request->GetVar('uid', 'session'));
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $success = MetabaseRollbackTransaction($gDatabase);
             $errorhandler->display('SQL', 'Article::saveupdatePeriod()', $query);
         }
     }
     // update
     if ($periodid !== '-1') {
         $query = sprintf("UPDATE {$tbl_period} SET \n\t\t\t                 period = %s, \n\t\t\t\t\t\t\t active = %s,\n\t\t\t\t\t\t\t updated_date = NOW(), \n\t\t\t\t\t\t\t fk_updated_user_id = %s \n\t\t\t\t\t\t\t WHERE pk_period_id = %s ", MetabaseGetTextFieldValue($gDatabase, $request->GetVar('frm_perioddesc', 'post')), MetabaseGetBooleanFieldValue($gDatabase, $active), $request->GetVar('uid', 'session'), $periodid);
     } else {
         // new
         $name = "zvs_pk_period_id";
         $sequence = MetabaseGetSequenceNextValue($gDatabase, $name, &$periodid);
         $query = sprintf("INSERT INTO {$tbl_period}\n\t\t\t                  (pk_period_id, period, active, inserted_date, fk_inserted_user_id, updated_date, fk_updated_user_id)\n\t\t\t\t\t\t\t  VALUES (%s, %s, %s, NOW(), %s, NULL, NULL )", $periodid, MetabaseGetTextFieldValue($gDatabase, $request->GetVar('frm_perioddesc', 'post')), MetabaseGetBooleanFieldValue($gDatabase, $active), $request->GetVar('uid', 'session'));
     }
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Article::saveupdatePeriod()', $query);
     } else {
         if ($request->GetVar('frm_cpyperiod', 'post') != -1) {
             $query = "SELECT fk_bararticlecat_id, description, price, hotkey\n\t\t\t\t\t  FROM {$tbl_bararticle} \n\t\t\t\t\t  WHERE ISNULL(deleted_date) AND\n\t\t\t\t\t  fk_period_id = " . $request->GetVar('frm_cpyperiod', 'post');
             $result = MetabaseQuery($gDatabase, $query);
             if (!$result) {
                 $success = MetabaseRollbackTransaction($gDatabase);
                 $errorhandler->display('SQL', 'Article::saveupdatePeriod()', $query);
             }
             for ($row = 0; ($eor = MetabaseEndOfResult($gDatabase, $result)) == 0; ++$row) {
                 $name = "zvs_pk_bararticle_id";
                 $sequence = MetabaseGetSequenceNextValue($gDatabase, $name, &$bararticleid);
                 $query = sprintf("INSERT INTO {$tbl_bararticle} \n\t\t\t\t\t         (pk_bararticle_id, fk_period_id, fk_bararticlecat_id,\n\t\t\t\t\t\t\t description, price, hotkey, inserted_date, \n\t\t\t\t\t\t\t fk_inserted_user_id)\n\t\t\t\t\t\t\t VALUES (%s, %s, %s, %s, %s, %s, NOW(), %s) ", $bararticleid, $periodid, MetabaseFetchResult($gDatabase, $result, $row, 0), MetabaseGetTextFieldValue($gDatabase, MetabaseFetchResult($gDatabase, $result, $row, 1)), MetabaseGetTextFieldValue($gDatabase, MetabaseFetchResult($gDatabase, $result, $row, 2)), MetabaseGetTextFieldValue($gDatabase, MetabaseFetchResult($gDatabase, $result, $row, 3)), $request->GetVar('uid', 'session'));
                 $result2 = MetabaseQuery($gDatabase, $query);
                 if (!$result2) {
                     $success = MetabaseRollbackTransaction($gDatabase);
                     $errorhandler->display('SQL', 'Article::saveupdatePeriod()', $query);
                 }
             }
         }
         $success = MetabaseCommitTransaction($gDatabase);
         // end transaction
         $auto_commit = true;
         $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
     }
     return $periodid;
 }
예제 #3
0
 function AlterDatabase(&$previous_definition, &$changes)
 {
     if (isset($changes["TABLES"])) {
         for ($change = 0, Reset($changes["TABLES"]); $change < count($changes["TABLES"]); Next($changes["TABLES"]), $change++) {
             $table_name = Key($changes["TABLES"]);
             if (isset($changes["TABLES"][$table_name]["Add"]) || isset($changes["TABLES"][$table_name]["Remove"])) {
                 continue;
             }
             if (!MetabaseAlterTable($this->database, $table_name, $changes["TABLES"][$table_name], 1)) {
                 return "database driver is not able to perform the requested alterations: " . MetabaseError($this->database);
             }
         }
     }
     if (isset($changes["SEQUENCES"])) {
         if (!MetabaseSupport($this->database, "Sequences")) {
             return "sequences are not supported";
         }
         for ($change = 0, Reset($changes["SEQUENCES"]); $change < count($changes["SEQUENCES"]); Next($changes["SEQUENCES"]), $change++) {
             $sequence_name = Key($changes["SEQUENCES"]);
             if (isset($changes["SEQUENCES"][$sequence_name]["Add"]) || isset($changes["SEQUENCES"][$sequence_name]["Remove"]) || isset($changes["SEQUENCES"][$sequence_name]["Change"])) {
                 continue;
             }
             return "some sequences changes are not yet supported";
         }
     }
     if (isset($changes["INDEXES"])) {
         if (!MetabaseSupport($this->database, "Indexes")) {
             return "indexes are not supported";
         }
         for ($change = 0, Reset($changes["INDEXES"]); $change < count($changes["INDEXES"]); Next($changes["INDEXES"]), $change++) {
             $table_name = Key($changes["INDEXES"]);
             $table_changes = count($changes["INDEXES"][$table_name]);
             if (isset($changes["INDEXES"][$table_name]["AddedIndexes"])) {
                 $table_changes--;
             }
             if (isset($changes["INDEXES"][$table_name]["RemovedIndexes"])) {
                 $table_changes--;
             }
             if (isset($changes["INDEXES"][$table_name]["ChangedIndexes"])) {
                 $table_changes--;
             }
             if ($table_changes) {
                 return "index alteration not yet supported";
             }
         }
     }
     $previous_database_name = MetabaseSetDatabase($this->database, $this->database_definition["name"]);
     if (($support_transactions = MetabaseSupport($this->database, "Transactions")) && !MetabaseAutoCommitTransactions($this->database, 0)) {
         return MetabaseError($this->database);
     }
     $error = "";
     $alterations = 0;
     if (isset($changes["INDEXES"])) {
         for ($change = 0, Reset($changes["INDEXES"]); $change < count($changes["INDEXES"]); Next($changes["INDEXES"]), $change++) {
             $table_name = Key($changes["INDEXES"]);
             if (isset($changes["INDEXES"][$table_name]["RemovedIndexes"])) {
                 $indexes = $changes["INDEXES"][$table_name]["RemovedIndexes"];
                 for ($index = 0, Reset($indexes); $index < count($indexes); Next($indexes), $index++) {
                     if (!MetabaseDropIndex($this->database, $table_name, Key($indexes))) {
                         $error = MetabaseError($this->database);
                         break;
                     }
                     $alterations++;
                 }
             }
             if (!strcmp($error, "") && isset($changes["INDEXES"][$table_name]["ChangedIndexes"])) {
                 $indexes = $changes["INDEXES"][$table_name]["ChangedIndexes"];
                 for ($index = 0, Reset($indexes); $index < count($indexes); Next($indexes), $index++) {
                     $name = Key($indexes);
                     $was_name = isset($indexes[$name]["name"]) ? $indexes[$name]["name"] : $name;
                     if (!MetabaseDropIndex($this->database, $table_name, $was_name)) {
                         $error = MetabaseError($this->database);
                         break;
                     }
                     $alterations++;
                 }
             }
             if (strcmp($error, "")) {
                 break;
             }
         }
     }
     if (!strcmp($error, "") && isset($changes["TABLES"])) {
         for ($change = 0, Reset($changes["TABLES"]); $change < count($changes["TABLES"]); Next($changes["TABLES"]), $change++) {
             $table_name = Key($changes["TABLES"]);
             if (isset($changes["TABLES"][$table_name]["Remove"])) {
                 if (!strcmp($error = $this->DropTable($table_name), "")) {
                     $alterations++;
                 }
             } else {
                 if (!isset($changes["TABLES"][$table_name]["Add"])) {
                     if (!MetabaseAlterTable($this->database, $table_name, $changes["TABLES"][$table_name], 0)) {
                         $error = MetabaseError($this->database);
                     } else {
                         $alterations++;
                     }
                 }
             }
             if (strcmp($error, "")) {
                 break;
             }
         }
         for ($change = 0, Reset($changes["TABLES"]); $change < count($changes["TABLES"]); Next($changes["TABLES"]), $change++) {
             $table_name = Key($changes["TABLES"]);
             if (isset($changes["TABLES"][$table_name]["Add"])) {
                 if (!strcmp($error = $this->CreateTable($table_name, $this->database_definition["TABLES"][$table_name]), "")) {
                     $alterations++;
                 }
             }
             if (strcmp($error, "")) {
                 break;
             }
         }
     }
     if (!strcmp($error, "") && isset($changes["SEQUENCES"])) {
         for ($change = 0, Reset($changes["SEQUENCES"]); $change < count($changes["SEQUENCES"]); Next($changes["SEQUENCES"]), $change++) {
             $sequence_name = Key($changes["SEQUENCES"]);
             if (isset($changes["SEQUENCES"][$sequence_name]["Add"])) {
                 $created_on_table = 0;
                 if (isset($this->database_definition["SEQUENCES"][$sequence_name]["on"])) {
                     $table = $this->database_definition["SEQUENCES"][$sequence_name]["on"]["table"];
                     if (isset($changes["TABLES"]) && isset($changes["TABLES"][$table_name]) && isset($changes["TABLES"][$table_name]["Add"])) {
                         $created_on_table = 1;
                     }
                 }
                 if (!strcmp($error = $this->CreateSequence($sequence_name, $this->database_definition["SEQUENCES"][$sequence_name], $created_on_table), "")) {
                     $alterations++;
                 }
             } else {
                 if (isset($changes["SEQUENCES"][$sequence_name]["Remove"])) {
                     if (!strcmp($error = $this->DropSequence($sequence_name), "")) {
                         $alterations++;
                     }
                 } else {
                     if (isset($changes["SEQUENCES"][$sequence_name]["Change"])) {
                         $created_on_table = 0;
                         if (isset($this->database_definition["SEQUENCES"][$sequence_name]["on"])) {
                             $table = $this->database_definition["SEQUENCES"][$sequence_name]["on"]["table"];
                             if (isset($changes["TABLES"]) && isset($changes["TABLES"][$table_name]) && isset($changes["TABLES"][$table_name]["Add"])) {
                                 $created_on_table = 1;
                             }
                         }
                         if (!strcmp($error = $this->DropSequence($this->database_definition["SEQUENCES"][$sequence_name]["was"]), "") && !strcmp($error = $this->CreateSequence($sequence_name, $this->database_definition["SEQUENCES"][$sequence_name], $created_on_table), "")) {
                             $alterations++;
                         }
                     } else {
                         $error = "changing sequences is not yet supported";
                     }
                 }
             }
             if (strcmp($error, "")) {
                 break;
             }
         }
     }
     if (!strcmp($error, "") && isset($changes["INDEXES"])) {
         for ($change = 0, Reset($changes["INDEXES"]); $change < count($changes["INDEXES"]); Next($changes["INDEXES"]), $change++) {
             $table_name = Key($changes["INDEXES"]);
             if (isset($changes["INDEXES"][$table_name]["ChangedIndexes"])) {
                 $indexes = $changes["INDEXES"][$table_name]["ChangedIndexes"];
                 for ($index = 0, Reset($indexes); $index < count($indexes); Next($indexes), $index++) {
                     if (!MetabaseCreateIndex($this->database, $table_name, Key($indexes), $this->database_definition["TABLES"][$table_name]["INDEXES"][Key($indexes)])) {
                         $error = MetabaseError($this->database);
                         break;
                     }
                     $alterations++;
                 }
             }
             if (!strcmp($error, "") && isset($changes["INDEXES"][$table_name]["AddedIndexes"])) {
                 $indexes = $changes["INDEXES"][$table_name]["AddedIndexes"];
                 for ($index = 0, Reset($indexes); $index < count($indexes); Next($indexes), $index++) {
                     if (!MetabaseCreateIndex($this->database, $table_name, Key($indexes), $this->database_definition["TABLES"][$table_name]["INDEXES"][Key($indexes)])) {
                         $error = MetabaseError($this->database);
                         break;
                     }
                     $alterations++;
                 }
             }
             if (strcmp($error, "")) {
                 break;
             }
         }
     }
     if ($alterations && strcmp($error, "")) {
         if ($support_transactions) {
             if (!MetabaseRollbackTransaction($this->database)) {
                 $error = "Could not rollback the partially implemented the requested database alterations: Rollback error: " . MetabaseError($this->database) . " Alterations error: {$error}";
             }
         } else {
             $error = "the requested database alterations were only partially implemented: {$error}";
         }
     }
     if ($support_transactions) {
         if (!MetabaseAutoCommitTransactions($this->database, 1)) {
             $this->warnings[] = "Could not end transaction after successfully implemented the requested database alterations: " . MetabaseError($this->database);
         }
     }
     MetabaseSetDatabase($this->database, $previous_database_name);
     return $error;
 }
예제 #4
0
 /**
  * Guest::shareaddress()
  * 
  * share address
  * 
  * @param string $shareid address id and type of source
  * @param number $guestid address id
  * @param string $type type of aim
  * @access public 
  * @since 2005-08-20
  * @author Christian Ehret <*****@*****.**> 
  */
 function shareaddress($shareid, $guestid, $type)
 {
     global $gDatabase, $tbl_guest_address, $tbl_address, $errorhandler;
     $sharetype = substr($shareid, 0, 1);
     $shareid = substr($shareid, 2);
     $type = ucfirst(substr($type, 0, 1));
     $auto_commit = false;
     $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
     $query = sprintf("SELECT pk_fk_address_id FROM {$tbl_guest_address}\n\t\t                  WHERE pk_fk_guest_id = %s\n\t\t\t\t\t\t  AND address_type = %s ", $guestid, MetabaseGetTextFieldValue($gDatabase, $type));
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Guest::shareaddress()', $query);
     }
     $oldaddressid = MetabaseFetchResult($gDatabase, $result, 0, 0);
     $query = sprintf("SELECT pk_fk_address_id FROM {$tbl_guest_address}\n\t\t                  WHERE pk_fk_guest_id = %s\n\t\t\t\t\t\t  AND address_type = %s ", $shareid, MetabaseGetTextFieldValue($gDatabase, $sharetype));
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Guest::shareaddress()', $query);
     }
     $newaddressid = MetabaseFetchResult($gDatabase, $result, 0, 0);
     if ($oldaddressid) {
         $query = sprintf("UPDATE {$tbl_guest_address} ga \n\t\t                  SET pk_fk_address_id = %s \n\t\t\t\t\t\t  WHERE pk_fk_guest_id = %s \n\t\t\t\t\t\t  AND address_type = %s", $newaddressid, $guestid, MetabaseGetTextFieldValue($gDatabase, $type));
     } else {
         $query = sprintf("INSERT INTO {$tbl_guest_address} \n\t\t\t\t\t\t  (pk_fk_guest_id, pk_fk_address_id, address_type) \n\t\t\t\t\t\t  VALUES (%s, %s, %s)", $guestid, $newaddressid, MetabaseGetTextFieldValue($gDatabase, $type));
     }
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Guest::shareaddress()', $query);
     }
     if ($oldaddressid) {
         // check if address is used more than this time
         $query = "SELECT count( * ) FROM {$tbl_guest_address} \n\t\t\t          WHERE pk_fk_address_id = {$oldaddressid}";
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $success = MetabaseRollbackTransaction($gDatabase);
             $errorhandler->display('SQL', 'Guest::shareaddress()', $query);
         } else {
             $count = MetabaseFetchResult($gDatabase, $result, 0, 0);
         }
         if ($count == 0) {
             $query = sprintf("DELETE FROM {$tbl_address} \n\t\t\t\t\t\t  WHERE pk_address_id = %s", $oldaddressid, MetabaseGetTextFieldValue($gDatabase, $type));
             $result = MetabaseQuery($gDatabase, $query);
             if (!$result) {
                 $success = MetabaseRollbackTransaction($gDatabase);
                 $errorhandler->display('SQL', 'Guest::shareaddress()', $query);
             }
         }
     }
     $success = MetabaseCommitTransaction($gDatabase);
     // end transaction
     $auto_commit = true;
     $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
 }
예제 #5
0
        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}";
            } else {
                $query = $queries[$i];
            }
            $result = MetabaseQuery($gDatabase, $query);
            if (!$result) {
                $success = MetabaseRollbackTransaction($gDatabase);
                $errorhandler->display('SQL', 'database', $query);
            }
        }
        $query = "SET FOREIGN_KEY_CHECKS = 0";
        $result = MetabaseQuery($gDatabase, $query);
        if (!$result) {
            $success = MetabaseRollbackTransaction($gDatabase);
            $errorhandler->display('SQL', 'database', $query);
        }
        $success = MetabaseCommitTransaction($gDatabase);
        // end transaction
        $auto_commit = true;
        $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
        $smarty->assign('tpl_ready', 'true');
    }
}
$smarty->display('database.tpl');
예제 #6
0
             $failed++;
             echo "Test {$test}: transaction commit did not make permanent the row that was inserted{$eol}";
         }
         MetabaseFreeResult($database, $result);
     }
 }
 if ($success && $pass) {
     if (!($result = MetabaseQuery($database, "DELETE FROM users"))) {
         $success = 0;
     }
 }
 if (!$success) {
     $error = MetabaseError($database);
     MetabaseRollbackTransaction($database);
 }
 if (!MetabaseAutoCommitTransactions($database, 1)) {
     if (strcmp($error, "")) {
         $error .= " and then could not end the transactions";
     }
     $success = 0;
 }
 MetabaseFreePreparedQuery($database, $prepared_query);
 if ($success && $pass) {
     if (!($result = MetabaseQuery($database, "SELECT * FROM users"))) {
         $success = 0;
     } else {
         if (!MetabaseEndOfResult($database, $result)) {
             $pass = 0;
             echo "FAILED!{$eol}";
             $failed++;
             echo "Test {$test}: transaction end with implicit commit when re-enabling auto-commit did not make permanent the rows that were deleted{$eol}";
예제 #7
0
 /**
  * price::save()
  * 
  * save prices for a season
  * 
  * @access public 
  * @since 2004-01-01
  * @author Christian Ehret <*****@*****.**> 
  */
 function save()
 {
     global $gDatabase, $request, $tbl_price, $tbl_price2, $errorhandler, $rcat, $bcat;
     // turn on Transaction Control
     $auto_commit = false;
     $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
     $seasonids = array();
     $seasonids = $request->getVar('frm_seasonid', 'post');
     $bcats = $bcat->Get();
     $rcats = $rcat->get('N');
     $rcats2 = $rcat->get('A');
     for ($i = 0; $i < count($seasonids); $i++) {
         // delete all old entries for the season for price normal
         $query = sprintf("DELETE FROM {$tbl_price} WHERE fk_season_id = %s", $seasonids[$i]);
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $success = MetabaseRollbackTransaction($gDatabase);
             $errorhandler->display('SQL', 'Price::save()', $query);
         }
         // delete all old entries for the season for price advanced
         $query = sprintf("DELETE FROM {$tbl_price2} WHERE fk_season_id = %s", $seasonids[$i]);
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $success = MetabaseRollbackTransaction($gDatabase);
             $errorhandler->display('SQL', 'Price::save()', $query);
         }
         // insert new values
         for ($j = 0; $j < count($bcats); $j++) {
             for ($k = 0; $k < count($rcats); $k++) {
                 $frmperson = "frm_price_adult_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmperson_short = "frm_price_adult_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmchildren = "frm_price_child_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmchildren_short = "frm_price_child_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmchildren2 = "frm_price_child2_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmchildren2_short = "frm_price_child2_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmchildren3 = "frm_price_child3_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmchildren3_short = "frm_price_child3_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmabsolute = "frm_price_pausch_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmabsolute_short = "frm_price_pausch_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $frmtype = "frm_type_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats[$k][catid];
                 $priceperson = 0.0;
                 $pricepersonshort = 0.0;
                 $pricechildren = 0.0;
                 $pricechildrenshort = 0.0;
                 $pricechildren2 = 0.0;
                 $pricechildren2short = 0.0;
                 $pricechildren3 = 0.0;
                 $pricechildren3short = 0.0;
                 if ($request->GetVar($frmperson, 'post') !== "") {
                     $priceperson = $request->GetVar($frmperson, 'post');
                 }
                 if ($request->GetVar($frmperson_short, 'post') !== "") {
                     $pricepersonshort = $request->GetVar($frmperson_short, 'post');
                 }
                 if ($request->GetVar($frmchildren, 'post') !== "") {
                     $pricechildren = $request->GetVar($frmchildren, 'post');
                 }
                 if ($request->GetVar($frmchildren_short, 'post') !== "") {
                     $pricechildrenshort = $request->GetVar($frmchildren_short, 'post');
                 }
                 if ($request->GetVar($frmchildren2, 'post') !== "") {
                     $pricechildren2 = $request->GetVar($frmchildren2, 'post');
                 }
                 if ($request->GetVar($frmchildren2_short, 'post') !== "") {
                     $pricechildren2short = $request->GetVar($frmchildren2_short, 'post');
                 }
                 if ($request->GetVar($frmchildren3, 'post') !== "") {
                     $pricechildren3 = $request->GetVar($frmchildren3, 'post');
                 }
                 if ($request->GetVar($frmchildren3_short, 'post') !== "") {
                     $pricechildren3short = $request->GetVar($frmchildren3_short, 'post');
                 }
                 $name = "zvs_pk_price_id";
                 $sequence = MetabaseGetSequenceNextValue($gDatabase, $name, &$priceid);
                 $query = sprintf("INSERT INTO {$tbl_price}\n\t\t\t\t\t\t\t\t  (pk_price_id, fk_roomcat_id, fk_bookingcat_id,\n\t\t\t\t\t\t\t\t   fk_season_id, price_person, price_children, \n\t\t\t\t\t\t\t\t   price_type, inserted_date, fk_inserted_user_id, \n\t\t\t\t\t\t\t\t   price_person_short, price_children_short,\n\t\t\t\t\t\t\t\t   price_children2, price_children2_short, price_children3, price_children3_short) \n\t\t\t\t\t\t\t\t   VALUES\n\t\t\t\t\t\t\t\t   (%s, %s, %s, %s, %s, %s, %s, NOW(), %s, %s, %s, %s, %s, %s, %s) ", $priceid, $rcats[$k][catid], $bcats[$j][bcatid], $seasonids[$i], $priceperson, $pricechildren, MetabaseGetTextFieldValue($gDatabase, 'PP'), $request->GetVar('uid', 'session'), $pricepersonshort, $pricechildrenshort, $pricechildren2, $pricechildren2short, $pricechildren3, $pricechildren3short);
                 $result = MetabaseQuery($gDatabase, $query);
                 if (!$result) {
                     $success = MetabaseRollbackTransaction($gDatabase);
                     $errorhandler->display('SQL', 'Price::save()', $query);
                 }
             }
             for ($k = 0; $k < count($rcats2); $k++) {
                 $frmprice = "frm_price_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats2[$k][catid];
                 $frmprice_short = "frm_price_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats2[$k][catid];
                 $frmperson = "frm_person_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats2[$k][catid];
                 $frmadditional = "frm_additional_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats2[$k][catid];
                 $frmadditional_short = "frm_additional_short_" . $seasonids[$i] . "_" . $bcats[$j][bcatid] . "_" . $rcats2[$k][catid];
                 $price = 0.0;
                 $priceshort = 0.0;
                 $additional = 0.0;
                 $additionalshort = 0.0;
                 if ($request->GetVar($frmprice, 'post') !== "") {
                     $price = $request->GetVar($frmprice, 'post');
                 }
                 if ($request->GetVar($frmprice_short, 'post') !== "") {
                     $priceshort = $request->GetVar($frmprice_short, 'post');
                 }
                 if ($request->GetVar($frmadditional, 'post') !== "") {
                     $additional = $request->GetVar($frmadditional, 'post');
                 }
                 if ($request->GetVar($frmadditional_short, 'post') !== "") {
                     $additionalshort = $request->GetVar($frmadditional_short, 'post');
                 }
                 $name = "zvs_pk_price2_id";
                 $sequence = MetabaseGetSequenceNextValue($gDatabase, $name, &$priceid);
                 $query = sprintf("INSERT INTO {$tbl_price2}\n\t\t\t\t\t\t\t\t  (pk_price2_id, fk_roomcat_id, fk_bookingcat_id,\n\t\t\t\t\t\t\t\t   fk_season_id, price, price_short, \n\t\t\t\t\t\t\t\t   persons_included, price_additional, price_short_additional,\n\t\t\t\t\t\t\t\t   inserted_date, fk_inserted_user_id) \n\t\t\t\t\t\t\t\t   VALUES\n\t\t\t\t\t\t\t\t   (%s, %s, %s, %s, %s, %s, %s, %s, %s, NOW(), %s) ", $priceid, $rcats2[$k][catid], $bcats[$j][bcatid], $seasonids[$i], $price, $priceshort, MetabaseGetTextFieldValue($gDatabase, $request->GetVar($frmperson, 'post')), $additional, $additionalshort, $request->GetVar('uid', 'session'));
                 $result = MetabaseQuery($gDatabase, $query);
                 if (!$result) {
                     $success = MetabaseRollbackTransaction($gDatabase);
                     $errorhandler->display('SQL', 'Price::save()', $query);
                 }
             }
         }
     }
     $success = MetabaseCommitTransaction($gDatabase);
     // end transaction
     $auto_commit = true;
     $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
 }
예제 #8
0
 /**
  * price::deletedraft()
  * 
  * delete draft receipt
  * 
  * @param number $draftreceiptid draft receipt id
  * @param boolean $transc transaction control
  * @access public 
  * @since 2004-04-18
  * @author Christian Ehret <*****@*****.**> 
  */
 function deletedraft($draftreceiptid, $transc)
 {
     global $gDatabase, $tbl_draftreceipt, $tbl_draftreceipt_booking, $tbl_draftreceipt_item, $errorhandler, $request;
     if ($transc) {
         $auto_commit = false;
         $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
     }
     $query = "DELETE FROM {$tbl_draftreceipt_item} WHERE fk_draftreceipt_id = " . $draftreceiptid;
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Receipt::deletedraft()', $query);
     }
     $query = "DELETE FROM {$tbl_draftreceipt_booking} WHERE pk_fk_draftreceipt_id = " . $draftreceiptid;
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Receipt::deletedraft()', $query);
     }
     $query = "DELETE FROM {$tbl_draftreceipt} WHERE pk_draftreceipt_id = " . $draftreceiptid;
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Receipt::deletedraft()', $query);
     } else {
         if ($transc) {
             $success = MetabaseCommitTransaction($gDatabase);
             // end transaction
             $auto_commit = true;
             $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
         }
     }
 }
예제 #9
0
             if ($success && $pass) {
                 $passed++;
                 echo "OK.{$eol}";
             }
         }
     } else {
         echo "Transactions are not supported.{$eol}";
     }
 }
 if (isset($tests["nestedtransactions"]) && $success) {
     if (MetabaseSupport($database, "Transactions")) {
         $test = "transactions";
         echo "Testing nested transactions... ";
         flush();
         $pass = 1;
         if (!MetabaseAutoCommitTransactions($database, 0) || !MetabaseAutoCommitTransactions($database, 0) || !MetabaseCommitTransaction($database) || !MetabaseAutoCommitTransactions($database, 1) || !MetabaseRollbackTransaction($database) || !MetabaseAutoCommitTransactions($database, 1)) {
             $success = 0;
         }
         if ($success && $pass) {
             $passed++;
             echo "OK.{$eol}";
         }
     } else {
         echo "Transactions are not supported.{$eol}";
     }
 }
 if (MetabaseSupport($database, "PatternBuild") && isset($tests["patterns"]) && $success) {
     $test = "patterns";
     echo "Testing queries with pattern matching conditions... ";
     $values = array(1 => "%end", 2 => "begin%end", 3 => "begin%", 4 => "beginend", 5 => "_end", 6 => "begin_end", 7 => "begin_", 8 => "beginend", 9 => " _@%\\ ]['?*");
     flush();
예제 #10
0
 /**
  * Booking::deloldreservation()
  * 
  * This function marks an old reservation as deleted
  * 
  * @param number $bookingid booking id
  * @access public 
  * @since 2004-02-07
  * @author Christian Ehret <*****@*****.**> 
  */
 function deloldreservation($bookingid)
 {
     global $tbl_booking, $tbl_booking_detail, $gDatabase, $request, $errorhandler;
     // transaction control
     $auto_commit = false;
     $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
     $query = sprintf("UPDATE {$tbl_booking} \n\t\t                  SET deleted_date = NOW(), \n\t\t\t\t\t\t  fk_deleted_user_id = %s \n\t\t\t\t\t\t  WHERE pk_booking_id = %s ", 1, MetabaseGetTextFieldValue($gDatabase, $bookingid));
     $result = MetabaseQuery($gDatabase, $query);
     if (!$result) {
         $success = MetabaseRollbackTransaction($gDatabase);
         $errorhandler->display('SQL', 'Booking::deloldreservation()', $query);
     } else {
         $query = sprintf("UPDATE {$tbl_booking_detail} \n\t\t\t\t\t\t\t   SET deleted_date = NOW(), \n\t\t\t\t\t\t\t   fk_deleted_user_id = %s \n\t\t\t\t\t\t\t   WHERE fk_booking_id = %s ", 1, MetabaseGetTextFieldValue($gDatabase, $bookingid));
         $result = MetabaseQuery($gDatabase, $query);
         if (!$result) {
             $success = MetabaseRollbackTransaction($gDatabase);
             $errorhandler->display('SQL', 'Booking::deloldreservation()', $query);
         } else {
             $success = MetabaseCommitTransaction($gDatabase);
             // end transaction
             $auto_commit = true;
             $success = MetabaseAutoCommitTransactions($gDatabase, $auto_commit);
         }
     }
 }