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

📄 adodb-odbtp.inc.php

📁 一个bug追踪工具的PHP编写的源代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
			//print_r($constr);			$arr[$constr[11]][$constr[2]][] = $constr[7].'='.$constr[3];		}		if (!$arr) {			$false = false;			return $false;		}		$arr2 = array();		foreach($arr as $k => $v) {			foreach($v as $a => $b) {				if ($upper) $a = strtoupper($a);				$arr2[$a] = $b;			}		}		return $arr2;	}	function BeginTrans()	{		if (!$this->hasTransactions) return false;		if ($this->transOff) return true;		$this->transCnt += 1;		$this->autoCommit = false;		if (defined('ODB_TXN_DEFAULT'))			$txn = ODB_TXN_DEFAULT;		else			$txn = ODB_TXN_READUNCOMMITTED;		$rs = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS,$txn,$this->_connectionID);		if(!$rs) return false;		return true;	}	function CommitTrans($ok=true)	{		if ($this->transOff) return true;		if (!$ok) return $this->RollbackTrans();		if ($this->transCnt) $this->transCnt -= 1;		$this->autoCommit = true;		if( ($ret = @odbtp_commit($this->_connectionID)) )			$ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off		return $ret;	}	function RollbackTrans()	{		if ($this->transOff) return true;		if ($this->transCnt) $this->transCnt -= 1;		$this->autoCommit = true;		if( ($ret = @odbtp_rollback($this->_connectionID)) )			$ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off		return $ret;	}	function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)	{		// TOP requires ORDER BY for Visual FoxPro		if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) {			if (!preg_match('/ORDER[ \t\r\n]+BY/is',$sql)) $sql .= ' ORDER BY 1';		}		return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);	}	function Prepare($sql)	{		if (! $this->_bindInputArray) return $sql; // no binding		$stmt = @odbtp_prepare($sql,$this->_connectionID);		if (!$stmt) {		//	print "Prepare Error for ($sql) ".$this->ErrorMsg()."<br>";			return $sql;		}		return array($sql,$stmt,false);	}	function PrepareSP($sql)	{		if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures		$stmt = @odbtp_prepare_proc($sql,$this->_connectionID);		if (!$stmt) return false;		return array($sql,$stmt);	}	/*	Usage:		$stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group		# note that the parameter does not have @ in front!		$db->Parameter($stmt,$id,'myid');		$db->Parameter($stmt,$group,'group',false,64);		$db->Parameter($stmt,$group,'photo',false,100000,ODB_BINARY);		$db->Execute($stmt);		@param $stmt Statement returned by Prepare() or PrepareSP().		@param $var PHP variable to bind to. Can set to null (for isNull support).		@param $name Name of stored procedure variable name to bind to.		@param [$isOutput] Indicates direction of parameter 0/false=IN  1=OUT  2= IN/OUT. This is ignored in odbtp.		@param [$maxLen] Holds an maximum length of the variable.		@param [$type] The data type of $var. Legal values depend on driver.		See odbtp_attach_param documentation at http://odbtp.sourceforge.net.	*/	function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=0, $type=0)	{		if ( $this->odbc_driver == ODB_DRIVER_JET ) {			$name = '['.$name.']';			if( !$type && $this->_useUnicodeSQL				&& @odbtp_param_bindtype($stmt[1], $name) == ODB_CHAR )			{				$type = ODB_WCHAR;			}		}		else {			$name = '@'.$name;		}		return @odbtp_attach_param($stmt[1], $name, $var, $type, $maxLen);	}	/*		Insert a null into the blob field of the table first.		Then use UpdateBlob to store the blob.		Usage:		$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');		$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');	*/	function UpdateBlob($table,$column,$val,$where,$blobtype='image')	{		$sql = "UPDATE $table SET $column = ? WHERE $where";		if( !($stmt = @odbtp_prepare($sql, $this->_connectionID)) )			return false;		if( !@odbtp_input( $stmt, 1, ODB_BINARY, 1000000, $blobtype ) )			return false;		if( !@odbtp_set( $stmt, 1, $val ) )			return false;		return @odbtp_execute( $stmt ) != false;	}	function IfNull( $field, $ifNull )	{		switch( $this->odbc_driver ) {			case ODB_DRIVER_MSSQL:				return " ISNULL($field, $ifNull) ";			case ODB_DRIVER_JET:				return " IIF(IsNull($field), $ifNull, $field) ";		}		return " CASE WHEN $field is null THEN $ifNull ELSE $field END ";	}	function _query($sql,$inputarr=false)	{ 		if ($inputarr) {			if (is_array($sql)) {				$stmtid = $sql[1];			} else {				$stmtid = @odbtp_prepare($sql,$this->_connectionID);				if ($stmtid == false) {					$this->_errorMsg = $php_errormsg;					return false;				}			}			$num_params = @odbtp_num_params( $stmtid );			for( $param = 1; $param <= $num_params; $param++ ) {				@odbtp_input( $stmtid, $param );				@odbtp_set( $stmtid, $param, $inputarr[$param-1] );			}			if (!@odbtp_execute($stmtid) ) {				return false;			}		} else if (is_array($sql)) {			$stmtid = $sql[1];			if (!@odbtp_execute($stmtid)) {				return false;			}		} else {			$stmtid = @odbtp_query($sql,$this->_connectionID);   		}		$this->_lastAffectedRows = 0;		if ($stmtid) {				$this->_lastAffectedRows = @odbtp_affected_rows($stmtid);		}        return $stmtid;	}	function _close()	{		$ret = @odbtp_close($this->_connectionID);		$this->_connectionID = false;		return $ret;	}}class ADORecordSet_odbtp extends ADORecordSet {	var $databaseType = 'odbtp';	var $canSeek = true;	function ADORecordSet_odbtp($queryID,$mode=false)	{		if ($mode === false) {			global $ADODB_FETCH_MODE;			$mode = $ADODB_FETCH_MODE;		}		$this->fetchMode = $mode;		$this->ADORecordSet($queryID);	}	function _initrs()	{		$this->_numOfFields = @odbtp_num_fields($this->_queryID);		if (!($this->_numOfRows = @odbtp_num_rows($this->_queryID)))			$this->_numOfRows = -1;		if (!$this->connection->_useUnicodeSQL) return;		if ($this->connection->odbc_driver == ODB_DRIVER_JET) {			if (!@odbtp_get_attr(ODB_ATTR_MAPCHARTOWCHAR,			                     $this->connection->_connectionID))			{				for ($f = 0; $f < $this->_numOfFields; $f++) {					if (@odbtp_field_bindtype($this->_queryID, $f) == ODB_CHAR)						@odbtp_bind_field($this->_queryID, $f, ODB_WCHAR);				}			}		}	}	function &FetchField($fieldOffset = 0)	{		$off=$fieldOffset; // offsets begin at 0		$o= new ADOFieldObject();		$o->name = @odbtp_field_name($this->_queryID,$off);		$o->type = @odbtp_field_type($this->_queryID,$off);        $o->max_length = @odbtp_field_length($this->_queryID,$off);		if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);		else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);		return $o;	}	function _seek($row)	{		return @odbtp_data_seek($this->_queryID, $row);	}	function fields($colname)	{		if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];		if (!$this->bind) {			$this->bind = array();			for ($i=0; $i < $this->_numOfFields; $i++) {				$name = @odbtp_field_name( $this->_queryID, $i );				$this->bind[strtoupper($name)] = $i;			}		}		return $this->fields[$this->bind[strtoupper($colname)]];	}	function _fetch_odbtp($type=0)	{		switch ($this->fetchMode) {			case ADODB_FETCH_NUM:				$this->fields = @odbtp_fetch_row($this->_queryID, $type);				break;			case ADODB_FETCH_ASSOC:				$this->fields = @odbtp_fetch_assoc($this->_queryID, $type);				break;            default:				$this->fields = @odbtp_fetch_array($this->_queryID, $type);		}		return is_array($this->fields);	}	function _fetch()	{		return $this->_fetch_odbtp();	}	function MoveFirst()	{		if (!$this->_fetch_odbtp(ODB_FETCH_FIRST)) return false;		$this->EOF = false;		$this->_currentRow = 0;		return true;    }	function MoveLast()	{		if (!$this->_fetch_odbtp(ODB_FETCH_LAST)) return false;		$this->EOF = false;		$this->_currentRow = $this->_numOfRows - 1;		return true;	}	function NextRecordSet()	{		if (!@odbtp_next_result($this->_queryID)) return false;		$this->_inited = false;		$this->bind = false;		$this->_currentRow = -1;		$this->Init();		return true;	}	function _close()	{		return @odbtp_free_query($this->_queryID);	}}class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {	var $databaseType = 'odbtp_mssql';	function ADORecordSet_odbtp_mssql($id,$mode=false)	{		return $this->ADORecordSet_odbtp($id,$mode);	}}class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {	var $databaseType = 'odbtp_access';	function ADORecordSet_odbtp_access($id,$mode=false)	{		return $this->ADORecordSet_odbtp($id,$mode);	}}class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {	var $databaseType = 'odbtp_vfp';	function ADORecordSet_odbtp_vfp($id,$mode=false)	{		return $this->ADORecordSet_odbtp($id,$mode);	}}class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {	var $databaseType = 'odbtp_oci8';	function ADORecordSet_odbtp_oci8($id,$mode=false)	{		return $this->ADORecordSet_odbtp($id,$mode);	}}class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {	var $databaseType = 'odbtp_sybase';	function ADORecordSet_odbtp_sybase($id,$mode=false)	{		return $this->ADORecordSet_odbtp($id,$mode);	}}?>

⌨️ 快捷键说明

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