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

📄 db.php

📁 PHP-MYSQL FAST Finder Just follow the instructions given in the text file and you are done. ENJOY
💻 PHP
字号:
<?php/*** @package Library* This file only has the Db class in it.** @version     $Id: db.php,v 1.1 2004/10/08 02:06:01 chris Exp $* @author Chris <chris@interspire.com>* @filesource*/// Make sure these are set up.if (!defined('ERROR_FATAL')) define('ERROR_FATAL', E_USER_ERROR);if (!defined('ERROR_ERROR')) define('ERROR_ERROR', E_USER_WARNING);if (!defined('ERROR_WARNING')) define('ERROR_WARNING', E_USER_NOTICE);/*** @package Library* @subpackage Db* This is the base class for the database system.*/class Db {	/**	* @var connection   The global database connection.	* @see Connect	*/	var $connection = null;	/**	* @var _error       Where any database errors are stored.	* @see GetError	* @see SetError	* @access private	*/	var $_Error = null;	/**	* @var _ErrorLevel What type of error this is.	* @see GetError	* @see SetError	* @access private	*/	var $_ErrorLevel = ERROR_FATAL;	/**	* @var QueryLog Determines whether a query will be logged or not. If it's false or null it won't log, if it's a filename (or path to a file) it will log.	* @see LogQuery	*/	var $QueryLog = null;	/**	* Constructor	*	* Sets up the database connection.	* Since this is the parent class the others inherit from, this returns null when called directly.	*	* @return null	*/	function Db() {		return null;	}	/**	* Connect	*	* This function will connect to the database based on the details passed in.	* Since this is the parent class the others inherit from, this returns false when called directly.	*	* @return false	*/	function Connect() {		$this->SetError('Cannot call base class method Connect directly');		return false;	}	/**	* Disconnect	*	* This function will disconnect from the database resource passed in.	* Since this is the parent class the others inherit from, this returns false when called directly.	*	* @return false	*/	function Disconnect() {		$this->SetError('Cannot call base class method Disconnect directly');		return false;	}	/**	* SetError	*	* Stores the error in the _error var for retrieval.	* @param string The error you wish to store for retrieval.	* @param string The error level you wish to store.	*	* @access private	* @return void	*/	function SetError($error='', $errorlevel=ERROR_FATAL) {		$this->_Error = $error;		$this->_ErrorLevel = $errorlevel;	}	/**	* GetError	*	* This simply returns the $_Error var and it's error level.	*	* @access public	* @return array Returns the error and it's error level.	* @see SetError	*/	function GetError() {		return array($this->_Error, $this->_ErrorLevel);	}	/**	* Query	*	* This runs a query against the database and returns the resource result.	*	* @access public	* @return false Will always return false when called in the base class.	*/	function Query($query='') {		$this->SetError('Cannot call base class method Query directly');		return false;	}	/**	* Fetch	*	* This fetches a result from the result set passed in.	*	* @access public	* @return false Will always return false when called in the base class.	*/	function Fetch($resource=null) {		$this->SetError('Cannot call base class method Fetch directly');		return false;	}	/**	* Insert	*	* This function will run a database insert. It will return the ID of the record inserted.	*	* @access public	* @return false Will always return false when called in the base class.	*/	function Insert($query='') {		$this->SetError('Cannot call base class method Insert directly');		return false;	}	/**	* Update	*	* This function will run a database update. Returns whether the update worked or not.	*	* @access public	* @return false Will always return false when called in the base class.	*/	function Update($query='') {		$this->SetError('Cannot call base class method Update directly');		return false;	}	/**	* LogQuery	*	* This will log all queries if QueryLog is not false or null.	*	* @see QueryLog	*	* @return boolean Returns whether the query is logged or not. Will return false if there is no query or if the QueryLog variable is set to false or null.	*/	function LogQuery($query='') {		if (!$query) return false;		if (!$this->QueryLog || is_null($this->QueryLog)) return false;		if (!$fp = fopen($this->QueryLog, 'a+')) {			return false;		}		$query .= "\n";		fputs($fp, $query, strlen($query));		fclose($fp);		return true;	}	function FetchOne($result=null, $item=null) {		if (is_null($result) or is_null($item)) return false;		$row = $this->Fetch($result);		if (!isset($row[$item])) return false;		return stripslashes($row[$item]);	}}if (!function_exists('stripslashes_array')) {	// recursive function to remove slashes from an array or single keyword.	function stripslashes_array($array) {		if (is_array($array)) {			$return = array();			foreach($array as $key => $value) {				$key = stripslashes($key);				if (is_array($value)) {					$return[$key] = stripslashes_array($value);					continue;				}				$return[$key] = stripslashes($value);			}		} else {			$return = stripslashes($array);		}		return $return;	}}?>

⌨️ 快捷键说明

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