Location: PHPKode > projects > XDB Money > money/pnadodb/adodb-oci8po.inc.php
<?php
/*
V1.61 22 Nov 2001 (c) 2000, 2001 John Lim. All rights reserved.
  Released under both BSD license and Lesser GPL library license. 
  Whenever there is any discrepancy between the two licenses, 
  the BSD license will take precedence.

  Latest version is available at http://php.weblogs.com/
  
  Portable version of oci8, to make it more similar to other databases.
  The main differences are

   1. that the OCI_ASSOC names are in lowercase instead of uppercase.
   2. bind variables are mapped using ? instead of :<bindvar>

   Should some emulation of RecordCount() be implemented?
  
*/

include_once(ADODB_DIR.'/adodb-oci8.inc.php');

class ADODB_oci8po extends ADODB_oci8 {
    var $databaseType = 'oci8po';
	var $dataProvider = 'oci8po';
	
	
	// emulate handling of parameters ? ?, replacing with :bind0 :bind1
	function _query($sql,$inputarr)
	{
		if (is_array($inputarr)) {
			$i = 0;
			$sqlarr = explode('?',$sql);
			$sql = $sqlarr[0];
			foreach($inputarr as $v) {
				$name = 'bind'.$i++;
				$arr[$name] = $v;
				$sql .=  ":$name" . $sqlarr[$i];
			} 
			//print $sql;
			//print_r($arr);
		} else
			$arr = false;
		return ADODB_oci8::_query($sql,$arr);
	}

}

/*--------------------------------------------------------------------------------------
         Class Name: Recordset
--------------------------------------------------------------------------------------*/

class ADORecordset_oci8po extends ADORecordset_oci8 {

    var $databaseType = 'oci8po';
	
        function ADORecordset_oci8po($queryID)
        {
		global $ADODB_FETCH_MODE;
		
			$this->ADORecordset_oci8($queryID);
        }

		// lowercase field names...
 		function &_FetchField($fieldOffset = -1)
        {
                 $fld = new ADOFieldObject;
		 		 $fieldOffset += 1;
                 $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
                 $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
                 $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
				 if ($fld->type == 'NUMBER') {
				 	//$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
					$sc = OCIColumnScale($this->_queryID, $fieldOffset);
					if ($sc == 0) $fld->type = 'INT';
				 }
                 return $fld;
        }

	// 10% speedup to move MoveNext to child class
	function MoveNext() 
	{
		if (!$this->EOF) {		
			$this->_currentRow++;
			if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
				if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
				return true;
			}
			
			$this->EOF = true;
		}
		return false;
	}	
	
	/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
	function &GetArrayLimit($nrows,$offset=-1) 
	{
		if ($offset <= 0) return $this->GetArray($nrows);
		for ($i=1; $i < $offset; $i++) 
			if (!@OCIFetch($this->_queryID)) return array();
			
		if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return array();
		if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
		$results = array();
		$cnt = 0;
		while (!$this->EOF && $nrows != $cnt) {
			$results[$cnt++] = $this->fields;
			$this->MoveNext();
		}
		
		return $results;
	}

	// Uggh - a useless slowdown
	function _updatefields()
	{
		$arr = array();
		foreach ($this->fields as $k => $v) {
			if (is_integer($k)) $arr[$k] = $v;
			else $arr[strtolower($k)] = $v;
		}
		$this->fields = $arr;
	}
	
	function _fetch() 
	{
		$ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
		if ($ret && $this->fetchMode & OCI_ASSOC) $this->_updatefields();
		return $ret;
	}
}
?>
Return current item: XDB Money