Example #1
2
 public function get_json_data()
 {
     $lista = json_decode($this->field_list);
     $base = $this->db->getDB();
     $this->conn = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ={$base}", '', '') or exit('Cannot open with driver.');
     if (!$this->conn) {
         exit("Connection Failed: " . $this->conn);
     }
     $rs = odbc_exec($this->conn, $this->sql);
     if (!$rs) {
         exit("Error in SQL");
     }
     $value = '[';
     while (odbc_fetch_row($rs)) {
         $value .= '[';
         foreach ($lista as $valor) {
             $value .= $this->not_null(odbc_result($rs, $valor[0]), $valor[1]) . ',';
         }
         $value .= '],';
     }
     $value .= ']';
     $value = str_replace(",]", "]", $value);
     odbc_close_all();
     //$value = utf8_encode($value);
     return $value;
 }
Example #2
0
 public function connect($debug = false)
 {
     if (!function_exists('odbc_connect')) {
         Logger::warn("Virtuoso adapter requires PHP ODBC extension to be loaded");
         die;
     }
     odbc_close_all();
     $failedonce = false;
     while (false === ($con = @odbc_connect($this->dsn, $this->user, $this->pw))) {
         Logger::warn('ODBC connect to ' . $this->dsn . ' failed, waiting ' . self::wait . ' and retrying');
         sleep(self::wait);
     }
     if ($debug) {
         Logger::info('ODBC connection re-established');
     }
     $this->con = $con;
 }
Example #3
0
        $kdunit = odbc_result($Data, kdunit);
        $kdprogram = odbc_result($Data, kdprogram);
        $kdgiat = odbc_result($Data, kdgiat);
        $kdoutput = odbc_result($Data, kdoutput);
        $vol = odbc_result($Data, vol);
        if ($thang != $th) {
            $_SESSION['errmsg'] = "Seting Tahun tidak sesuai";
            ?>

				<meta http-equiv="refresh" content="0;URL=index.php?p=<?php 
            echo $p_next;
            ?>
"><?php 
            exit;
        }
        // cek data
        $sql = "INSERT INTO d_output VALUES('{$thang}', '{$kdsatker}', '{$kddept}', '{$kdunit}',\r\n\t\t\t\t\t'{$kdprogram}', '{$kdgiat}', '{$kdoutput}', '{$vol}')";
        mysql_query($sql);
        //echo "$tahun $kdsatker $vol<br>";
    }
    $_SESSION['errmsg'] = "Proses Import data berhasil";
    ?>
				<meta http-equiv="refresh" content="0;URL=index.php?p=<?php 
    echo $p_next;
    ?>
"><?php 
    exit;
    odbc_close_all();
}
?>
 
 private function loadIntoVirtuoso($odbc, $deleteSPARUL, $insertSPARUL, $graphURI)
 {
     $countdel = 0;
     $countins = 0;
     foreach ($deleteSPARUL as $key => $query) {
         Timer::start('LiveUpdateDestination::del::' . $key);
         //Logger::info('SPARUL'.$key);
         $this->executeUpdate($odbc, $query, $graphURI);
         //Logger::info('SPARUL'.$key);
         Timer::stop('LiveUpdateDestination::del::' . $key);
         $countdel++;
     }
     if (Options::getOption('debug_turn_off_insert')) {
         $this->log(INFO, 'no of queries, insert: ' . $countins . ' delete: ' . $countdel);
         odbc_close_all();
         return;
     }
     //if global batch is successfull
     Timer::start('LiveUpdateDestination::insertGlobalTriplePattern');
     //$timeWasted = microtime(true);
     $globalSuccess = $this->executeUpdate($odbc, $insertSPARUL['globalTriplePattern'], $graphURI);
     //$timeWasted = (microtime(true) - $timeWasted );
     //if(false === $globalSuccess){Timer::staticTimer('LiveUpdateDestination::insertFailedBecauseOfLongQuery', $timeWasted);}
     Timer::stop('LiveUpdateDestination::insertGlobalTriplePattern');
     $allGood = true;
     $stillAllGood = true;
     if (false === $globalSuccess) {
         //Logger::info('global insert of Triples failed, inserting each triple');
         Timer::start('LiveUpdateDestination::insertSingleTriples');
         foreach ($insertSPARUL['insert_triples'] as $query) {
             $countins++;
             $allGood = $allGood && $this->executeUpdate($odbc, $query, $graphURI);
         }
         Timer::stop('LiveUpdateDestination::insertSingleTriples');
     } else {
         $countins = 1;
     }
     if ($allGood) {
         $countins += 1;
         Timer::start('LiveUpdateDestination::insertGlobalAnnotationPattern');
         $stillAllGood = $this->executeUpdate($odbc, $insertSPARUL['globalAnnotationPattern'], $graphURI);
         Timer::stop('LiveUpdateDestination::insertGlobalAnnotationPattern');
     }
     if (!$stillAllGood) {
         //Logger::info('global insert of Annotations failed, inserting each triple');
         Timer::start('LiveUpdateDestination::insertSingleAnnotations');
         foreach ($insertSPARUL['insert_annotations'] as $query) {
             $countins++;
             $this->executeUpdate($odbc, $query, $graphURI);
         }
         Timer::stop('LiveUpdateDestination::insertSingleAnnotations');
     }
     $this->log(INFO, 'no of queries, insert: ' . $countins . ' delete: ' . $countdel);
 }
Example #5
0
 function close_all()
 {
     odbc_close_all();
 }
Example #6
0
 /**
  * When the router stops on a "fatal" error (i.e.
  * an exception that was not "catched" by the application),
  * we drop (for safety) all ODBC connections and the current PHP session.
  * We also take care to hide all E_NOTICE notifications.
  */
 private function cleanupOnFatalError()
 {
     // Persistent connections created with odbc_connect() are never released,
     // even when they become unusable (after that a database was restarted, for example).
     // An exception would then be thrown at each database access attempt, preventing subsequent
     // browsing within this application until the web server is restarted!
     // To avoid this situation, we try to reset all ODBC connections after each "fatal" error.
     if (DROP_ALL_ODBC_CONNECTIONS_ON_FATAL_ERROR && @function_exists('odbc_close_all')) {
         @odbc_close_all();
     }
     // Similarly, we destroy the session data, to avoid working on "corrupt" data.
     if (DROP_SESSION_ON_FATAL_ERROR && @session_id() !== '') {
         if (@ini_get('session.use_cookies')) {
             $params = @session_get_cookie_params();
             if (is_array($params)) {
                 @setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
             }
         }
         @session_unset();
         @session_destroy();
         @session_write_close();
     }
 }