$g_ora_session = 0;
$g_ora_db = 0;
// *******************************BEGIN CONFIGURATIONS************************************
define("G_ORA_LOGIN", "wsg_dblk@scdbdev"); // CONFIG for login and oracle instance name
define("G_ORA_PASSWORD", "wsg_dblk"); // CONFIG for password
define("G_ORA_ACCESS_ALL_TABLE", TRUE); // CONFIG for allow access all table
define("G_ORA_HOME_ENV",
"ORACLE_HOME=/oraexe/oracle/v8.1.7"); // CONFIG for Oracle HOME in Linux
//define("G_ORA_HOME_ENV",
// "ORACLE_HOME=c:/orant"); // CONFIG for Oracle HOME in Windows
// ********************************END CONFIGURATIONS*************************************
// connect to oracle and open database
function open_oracle_db()
{
global $g_ora_session;
global $g_ora_db;
if ((G_ORA_HOME_ENV != NULL) && (G_ORA_HOME_ENV != ""))
putenv(G_ORA_HOME_ENV); // CONFIG
//PrintTrace("G_ORA_LOGIN = " . G_ORA_LOGIN);
//PrintTrace("G_ORA_PASSWORD = " . G_ORA_PASSWORD);
$g_ora_session = ora_logon(G_ORA_LOGIN , G_ORA_PASSWORD) or
die(return_error(E_INTERNAL_SYSTEM_ERROR, "003"));
$g_ora_db = ora_open($g_ora_session) or
die(return_error(E_INTERNAL_SYSTEM_ERROR, "004"));
ora_commitoff($g_ora_session);
// set date format as yyyy-mm-dd
ora_parse($g_ora_db, "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
ora_exec($g_ora_db);
// allow access all table?
if (TRUE == G_ORA_ACCESS_ALL_TABLE) {
ora_parse($g_ora_db, "ALTER SESSION SET GLOBAL_NAMES=FALSE");
ora_exec($g_ora_db);
}
return $g_ora_db;
}
// close database and disconnect oracle.
function close_oracle_db()
{
global $g_ora_session;
global $g_ora_db;
if ($g_ora_db > 0)
{
ora_close($g_ora_db);
ora_logoff($g_ora_session);
}
$g_ora_db = 0;
$g_ora_session = 0;
}