⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db_tools.php

📁 Internet Task Management System可以让用户分配和管理一个组织内的任务。ITMS可以发送任务管理通知
💻 PHP
字号:
<?php/* * db_tools.php (Oracle Version) * To Use an Oracle DB for ITMS instead of MySQL, copy this version of the db_tools.php  * file over the one which comes with the full ITMS download * * This file will contain the basic functions needed to connect and disconnect from the database, * as well as issue queries to the database. * * ITMS ValleyData source file version 1.0 May 11, 2001 * * * * Internet Task Management System: An online system used for recording information about and assigning tasks and processes. * Copyright (C) 2001  ValleyData Programming Group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * * See file named "gpl.txt" included with source code or * visit http://www.gnu.org/copyleft/gpl.txt on the internet. */include("config.php");//include("object_dump.php");$g_query = "";$g_statement;//to specify which DB to usefunction db_use(){	if(func_num_args() == 0)	{		global $DB, $ORA_HOME_DIR, $TNS_ADMIN, $DB_HOST;		$dbname = $DB;        $ora_home = $ORA_HOME_DIR;		$tns = $TNS_ADMIN;        $hostname = $DB_HOST;	}	else if(func_num_args() == 1)	{        global $ORA_HOME_DIR, $TNS_ADMIN, $DB_HOST;		$dbname = func_get_arg(0);        $ora_home = $ORA_HOME_DIR;		$tns = $TNS_ADMIN;        $hostname = $DB_HOST;	}	else if(func_num_args() == 2)	{        global $TNS_ADMIN, $DB_HOST;		$dbname = func_get_arg(0);		$ora_home = func_get_arg(1); //path to oracle home directory									 //ex: /opt/oracle/oracle/8.0.3		$tns = $TNS_ADMIN;        $hostname = $DB_HOST;	}    else if(func_num_args() == 3)	{		global $DB_HOST;		$dbname = func_get_arg(0);		$ora_home = func_get_arg(1); //path to oracle home directory									 //ex: /opt/oracle/oracle/8.0.3		$tns = func_get_arg(2);        $hostname = $DB_HOST;	}	else if(func_num_args() == 4)	{		$dbname = func_get_arg(0);		$ora_home = func_get_arg(1); //path to oracle home directory									 //ex: /opt/oracle/oracle/8.0.3		$tns = func_get_arg(2);        $hostname = func_get_arg(3);	}	putenv("ORACLE_SID=" . $dbname)		or error_out("Could not use database: " . $dbname, "LOG_ERR");	putenv("ORACLE_HOME=" . $ora_home)		or error_out("Could find Oracle Home Directory: " . $ora_home, "LOG_ERR");	putenv("TNS_ADMIN=" . $tns); }		//to open a connection to the DBfunction db_open(){    /*	if(func_num_args() == 0)	{		global $DB_USERNAME;		global $DB_PASSWORD;		$username = $DB_USERNAME;		$password = $DB_PASSWORD;	}	else if(func_num_args() == 2)	{		$username = func_get_arg(0);		$password = func_get_arg(1);	}    $ret = @ora_logon($username, $password)        or error_out("Could not connect to db using username: $username", "LOG_ERR");    ora_commiton($ret);    $curs = ora_open($ret);    return $ret;    */    return null;}//to close the connection to the DBfunction db_close(){    @OCILogoff();        //or error_out("Could not close db", "LOG_WARNING");}//to issue a query to a connected DBfunction db_query($query, $report_errors = "true"){    if(func_num_args() == 1 || func_num_args() == 2)	{		global $DB_USERNAME;		global $DB_PASSWORD;		$username = $DB_USERNAME;		$password = $DB_PASSWORD;	}	else if(func_num_args() == 4)	{		$username = func_get_arg(0);		$password = func_get_arg(1);	}    $conn = OCILogon($username, $password)        or error_out("Could not connect to db using username: $username", "LOG_ERR");	if($report_errors != "NO_ERR")	{        $statement = OCIParse($conn, $query) //parse            or error_out("Could not execute query: " . $query, "LOG_ERR");				$resultset = OCIExecute($statement) //execute, fetch            or error_out("Could not execute query: " . $query, "LOG_ERR");		OCICommit($conn);	}	else //don't report errors	{		$statement = @OCIParse($conn, $query); //parse		$resultset = @OCIExecute($statement); //execute		OCICommit($conn);	}	global $g_query, $g_statement;	$g_query = $query;	$g_statement = $statement;    return $resultset;}//returns a row from the result of a sucessful call to the db_query functionfunction db_fetch_row($resultset, $report_errors = "false")  //default to not report errors on the fetch{	global $g_query, $g_statement;	//ocibindbyname($statement,"results",&$curs,-1,OCI_B_CURSOR);    array($results);    //OCIFetchStatement($g_query, $results, OCI_ASSOC);	if($report_errors == 'true')	{		OCIFetchInto($g_statement, &$results, OCI_ASSOC)			or error_out("Could not fetch query: " . $query, "LOG_ERR");	}	else	{		@OCIFetchInto($g_statement, &$results, OCI_ASSOC);	}		return $results;}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -