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

📄 adodb.inc.php

📁 股票监视器是一个简单的实用工具
💻 PHP
📖 第 1 页 / 共 5 页
字号:
		switch ($locale)		{			default:			case 'En':				$this->fmtDate="'Y-m-d'";				$this->fmtTimeStamp = "'Y-m-d H:i:s'";				break;				case 'Fr':			case 'Ro':			case 'It':				$this->fmtDate="'d-m-Y'";				$this->fmtTimeStamp = "'d-m-Y H:i:s'";				break;							case 'Ge':				$this->fmtDate="'d.m.Y'";				$this->fmtTimeStamp = "'d.m.Y H:i:s'";				break;		}	}		/**	 * Close Connection	 */	function Close()	{		$rez = $this->_close();		$this->_connectionID = false;		return $rez;	}		/**	 * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans().	 *	 * @return true if succeeded or false if database does not support transactions	 */	function BeginTrans() {return false;}			/**	 * If database does not support transactions, always return true as data always commited	 *	 * @param $ok  set to false to rollback transaction, true to commit	 *	 * @return true/false.	 */	function CommitTrans($ok=true) 	{ return true;}			/**	 * If database does not support transactions, rollbacks always fail, so return false	 *	 * @return true/false.	 */	function RollbackTrans() 	{ return false;}	/**	 * return the databases that the driver can connect to. 	 * Some databases will return an empty array.	 *	 * @return an array of database names.	 */		function MetaDatabases() 		{		global $ADODB_FETCH_MODE;					if ($this->metaDatabasesSQL) {				$save = $ADODB_FETCH_MODE; 				$ADODB_FETCH_MODE = ADODB_FETCH_NUM; 								if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);								$arr = $this->GetCol($this->metaDatabasesSQL);				if (isset($savem)) $this->SetFetchMode($savem);				$ADODB_FETCH_MODE = $save; 							return $arr;			}						return false;		}			/**	 * @param ttype can either be 'VIEW' or 'TABLE' or false. 	 * 		If false, both views and tables are returned.	 *		"VIEW" returns only views	 *		"TABLE" returns only tables	 * @param showSchema returns the schema/user with the table name, eg. USER.TABLE	 * @param mask  is the input mask - only supported by oci8 and postgresql	 *	 * @return  array of tables for current database.	 */ 	function &MetaTables($ttype=false,$showSchema=false,$mask=false) 	{	global $ADODB_FETCH_MODE;					$false = false;		if ($mask) {			return $false;		}		if ($this->metaTablesSQL) {			// complicated state saving by the need for backward compat			$save = $ADODB_FETCH_MODE; 			$ADODB_FETCH_MODE = ADODB_FETCH_NUM; 						if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);						$rs = $this->Execute($this->metaTablesSQL);			if (isset($savem)) $this->SetFetchMode($savem);			$ADODB_FETCH_MODE = $save; 						if ($rs === false) return $false;			$arr =& $rs->GetArray();			$arr2 = array();						if ($hast = ($ttype && isset($arr[0][1]))) { 				$showt = strncmp($ttype,'T',1);			}						for ($i=0; $i < sizeof($arr); $i++) {				if ($hast) {					if ($showt == 0) {						if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);					} else {						if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);					}				} else					$arr2[] = trim($arr[$i][0]);			}			$rs->Close();			return $arr2;		}		return $false;	}			function _findschema(&$table,&$schema)	{		if (!$schema && ($at = strpos($table,'.')) !== false) {			$schema = substr($table,0,$at);			$table = substr($table,$at+1);		}	}		/**	 * List columns in a database as an array of ADOFieldObjects. 	 * See top of file for definition of object.	 *	 * @param table	table name to query	 * @param upper	uppercase table name (required by some databases)	 * @schema is optional database schema to use - not supported by all databases.	 *	 * @return  array of ADOFieldObjects for current table.	 */	function &MetaColumns($table,$upper=true) 	{	global $ADODB_FETCH_MODE;				$false = false;				if (!empty($this->metaColumnsSQL)) {					$schema = false;			$this->_findschema($table,$schema);					$save = $ADODB_FETCH_MODE;			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;			if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);			$rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table));			if (isset($savem)) $this->SetFetchMode($savem);			$ADODB_FETCH_MODE = $save;			if ($rs === false || $rs->EOF) return $false;			$retarr = array();			while (!$rs->EOF) { //print_r($rs->fields);				$fld =& new ADOFieldObject();				$fld->name = $rs->fields[0];				$fld->type = $rs->fields[1];				if (isset($rs->fields[3]) && $rs->fields[3]) {					if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];					$fld->scale = $rs->fields[4];					if ($fld->scale>0) $fld->max_length += 1;				} else					$fld->max_length = $rs->fields[2];									if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;					else $retarr[strtoupper($fld->name)] = $fld;				$rs->MoveNext();			}			$rs->Close();			return $retarr;			}		return $false;	}	    /**      * List indexes on a table as an array.      * @param table  table name to query      * @param primary true to only show primary keys. Not actually used for most databases	  *      * @return array of indexes on current table. Each element represents an index, and is itself an associative array.	  		 Array (		    [name_of_index] => Array		      (	          [unique] => true or false	          [columns] => Array	          (	          	[0] => firstname		      	[1] => lastname	          )		)		      */     function &MetaIndexes($table, $primary = false, $owner = false)     {	 		$false = false;            return false;     }	/**	 * List columns names in a table as an array. 	 * @param table	table name to query	 *	 * @return  array of column names for current table.	 */ 	function &MetaColumnNames($table, $numIndexes=false) 	{		$objarr =& $this->MetaColumns($table);		if (!is_array($objarr)) {			$false = false;			return $false;		}		$arr = array();		if ($numIndexes) {			$i = 0;			foreach($objarr as $v) $arr[$i++] = $v->name;		} else			foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;				return $arr;	}				/**	 * Different SQL databases used different methods to combine strings together.	 * This function provides a wrapper. 	 * 	 * param s	variable number of string parameters	 *	 * Usage: $db->Concat($str1,$str2);	 * 	 * @return concatenated string	 */ 	 	function Concat()	{			$arr = func_get_args();		return implode($this->concat_operator, $arr);	}			/**	 * Converts a date "d" to a string that the database can understand.	 *	 * @param d	a date in Unix date time format.	 *	 * @return  date string in database date format	 */	function DBDate($d)	{		if (empty($d) && $d !== 0) return 'null';		if (is_string($d) && !is_numeric($d)) {			if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;			if ($this->isoDates) return "'$d'";			$d = ADOConnection::UnixDate($d);		}		return adodb_date($this->fmtDate,$d);	}			/**	 * Converts a timestamp "ts" to a string that the database can understand.	 *	 * @param ts	a timestamp in Unix date time format.	 *	 * @return  timestamp string in database timestamp format	 */	function DBTimeStamp($ts)	{		if (empty($ts) && $ts !== 0) return 'null';		# strlen(14) allows YYYYMMDDHHMMSS format		if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) 			return adodb_date($this->fmtTimeStamp,$ts);				if ($ts === 'null') return $ts;		if ($this->isoDates && strlen($ts) !== 14) return "'$ts'";				$ts = ADOConnection::UnixTimeStamp($ts);		return adodb_date($this->fmtTimeStamp,$ts);	}		/**	 * Also in ADORecordSet.	 * @param $v is a date string in YYYY-MM-DD format	 *	 * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format	 */	function UnixDate($v)	{		if (is_object($v)) {		// odbtp support		//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )			return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);		}			if (is_numeric($v) && strlen($v) !== 8) return $v;		if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", 			($v), $rr)) return false;		if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;		// h-m-s-MM-DD-YY		return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);	}		/**	 * Also in ADORecordSet.	 * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format	 *	 * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format	 */	function UnixTimeStamp($v)	{		if (is_object($v)) {		// odbtp support		//( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )			return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);		}				if (!preg_match( 			"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", 			($v), $rr)) return false;					if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;			// h-m-s-MM-DD-YY		if (!isset($rr[5])) return  adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);		return  @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);	}		/**	 * Also in ADORecordSet.	 *	 * Format database date based on user defined format.	 *	 * @param v  	is the character date in YYYY-MM-DD format, returned by database	 * @param fmt 	is the format to apply to it, using date()	 *	 * @return a date formated as user desires	 */	 	function UserDate($v,$fmt='Y-m-d',$gmt=false)	{		$tt = $this->UnixDate($v);		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR		if (($tt === false || $tt == -1) && $v != false) return $v;		else if ($tt == 0) return $this->emptyDate;		else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR		}				return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);		}			/**	 *	 * @param v  	is the character timestamp in YYYY-MM-DD hh:mm:ss format	 * @param fmt 	is the format to apply to it, using date()	 *	 * @return a timestamp formated as user desires	 */	function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)	{		# strlen(14) allows YYYYMMDDHHMMSS format		if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);		$tt = $this->UnixTimeStamp($v);		// $tt == -1 if pre TIMESTAMP_FIRST_YEAR		if (($tt === false || $tt == -1) && $v != false) return $v;		if ($tt == 0) return $this->emptyTimeStamp;		return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);	}		/**	* Quotes a string, without prefixing nor appending quotes. 	*/	function addq($s,$magic_quotes=false)	{		if (!$magic_quotes) {					if ($this->replaceQuote[0] == '\\'){				// only since php 4.0.5				$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);				//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));			}			return  str_replace("'",$this->replaceQuote,$s);		}				// undo magic quotes for "		$s = str_replace('\\"','"',$s);				if ($this->replaceQuote == "\\'")  // ' already quoted, no need to change anything			return $s;		else {// change \' to '' for sybase/mssql			$s = str_replace('\\\\','\\',$s);			return str_replace("\\'",$this->replaceQuote,$s);		}	}		/**	 * Correctly quotes a string so that all strings are escaped. We prefix and append	 * to the string single-quotes.	 * An example is  $db->qstr("Don't bother",magic_quotes_runtime());	 * 	 * @param s			the string to quote	 * @param [magic_quotes]	if $s is GET/POST var, set to get_magic_quotes_gpc().	 *				This undoes the stupidity of magic quotes for GPC.	 *	 * @return  quoted string to be sent back to database	 */	function qstr($s,$magic_quotes=false)	{			if (!$magic_quotes) {					if ($this->replaceQuote[0

⌨️ 快捷键说明

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