db_connect.php

来自「最近在做软交换时研究的一个软交换的东东」· PHP 代码 · 共 61 行

PHP
61
字号
<?php//Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)////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.require_once('DB.php'); //PEAR must be installed$db_engine = $amp_conf["AMPDBENGINE"];switch ($db_engine){	case "pgsql":	case "mysql":		/* datasource in in this style:		dbengine://username:password@host/database */				$db_user = $amp_conf["AMPDBUSER"];		$db_pass = $amp_conf["AMPDBPASS"];		$db_host = $amp_conf["AMPDBHOST"];		$db_name = 'asterisk';				$datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name;		$db = DB::connect($datasource); // attempt connection		break;			case "sqlite":		require_once('DB/sqlite.php');				if (!isset($amp_conf["AMPDBFILE"]))			die("You must setup properly AMPDBFILE in /etc/amportal.conf");					if (isset($amp_conf["AMPDBFILE"]) == "")			die("AMPDBFILE in /etc/amportal.conf cannot be blank");					$DSN = array (			"database" => $amp_conf["AMPDBFILE"],			"mode" => 0666		);				$db = new DB_sqlite();		$db->connect( $DSN );		break;		default:		die( "Unknown SQL engine: [$db_engine]");}// if connection failed show error// don't worry about this for now, we get to it in the errors sectionif(DB::isError($db)) {	die($db->getDebugInfo()); }

⌨️ 快捷键说明

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