<?php
/*
* dbupdate_oracle.php
* http://tasuke.dna.affrc.go.jp/
*
* Author: Ryutaro Itoh
*
* Copyright (c) 2013 National Institute of Agrobiological Sciences   
*
* This software is released under the MIT License.
*
* http://opensource.org/licenses/mit-license.php
*/

require '../../conf/config.php';

//////////////////////////////////  Connecting with DB
$conn = oci_connect($user, $pswd, $host."/".$db, "AL32UTF8");
if(!$conn) {
    $e = oci_error();
    error_log($e["message"]."\nConnection failed.\n");
    exit;
}

//DB
$update_time="0000-00-00 00:00:00";
#exec DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO;
$query = "select to_char(timestamp, 'yyyy/mm/dd hh24:mi:ss')time from all_tab_modifications where ROWNUM < 2 order by time desc";
$stmt = oci_parse($conn, $query);
oci_execute($stmt);
while (($row = oci_fetch_array($stmt, OCI_NUM + OCI_RETURN_NULLS))!= false) {
    $update_time=$row[0];
}
oci_free_statement($stmt);
oci_close($conn);

//DB config
$update_time .= ":".date('Y-m-d H:i:s', filemtime('../conf/config.php'));
echo $update_time;
?>

