Zikula 1.0.1
[ class tree: Zikula 1.0.1 ] [ index: Zikula 1.0.1 ] [ all elements ]

Source for file adodb-oci8po.inc.php

Documentation is available at adodb-oci8po.inc.php

  1. <?php
  2. /*
  3. V4.97 22 Jan 2008  (c) 2000-2008 John Lim. All rights reserved.
  4.   Released under both BSD license and Lesser GPL library license. 
  5.   Whenever there is any discrepancy between the two licenses, 
  6.   the BSD license will take precedence.
  7.  
  8.   Latest version is available at http://adodb.sourceforge.net
  9.   
  10.   Portable version of oci8 driver, to make it more similar to other database drivers.
  11.   The main differences are
  12.  
  13.    1. that the OCI_ASSOC names are in lowercase instead of uppercase.
  14.    2. bind variables are mapped using ? instead of :<bindvar>
  15.  
  16.    Should some emulation of RecordCount() be implemented?
  17.   
  18. */
  19.  
  20. // security - hide paths
  21. if (!defined('ADODB_DIR')) die();
  22.  
  23. include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
  24.  
  25. class ADODB_oci8po extends ADODB_oci8 {
  26.     var $databaseType = 'oci8po';
  27.     var $dataProvider = 'oci8';
  28.     var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"//changed by smondino@users.sourceforge. net
  29.     var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')";
  30.     
  31.     function ADODB_oci8po()
  32.     {
  33.         $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
  34.         # oci8po does not support adodb extension: adodb_movenext()
  35.     }
  36.     
  37.     function Param($name)
  38.     {
  39.         return '?';
  40.     }
  41.     
  42.     function Prepare($sql,$cursor=false)
  43.     {
  44.         $sqlarr explode('?',$sql);
  45.         $sql $sqlarr[0];
  46.         for ($i 1$max sizeof($sqlarr)$i $max$i++{
  47.             $sql .=  ':'.($i-1$sqlarr[$i];
  48.         
  49.         return ADODB_oci8::Prepare($sql,$cursor);
  50.     }
  51.     
  52.     // emulate handling of parameters ? ?, replacing with :bind0 :bind1
  53.     function _query($sql,$inputarr)
  54.     {
  55.         if (is_array($inputarr)) {
  56.             $i 0;
  57.             if (is_array($sql)) {
  58.                 foreach($inputarr as $v{
  59.                     $arr['bind'.$i++$v;
  60.                 
  61.             else {
  62.                 $sqlarr explode('?',$sql);
  63.                 $sql $sqlarr[0];
  64.                 foreach($inputarr as $k => $v{
  65.                     $sql .=  ":$k$sqlarr[++$i];
  66.                 }
  67.             }
  68.         }
  69.         return ADODB_oci8::_query($sql,$inputarr);
  70.     }
  71. }
  72.  
  73. /*--------------------------------------------------------------------------------------
  74.          Class Name: Recordset
  75. --------------------------------------------------------------------------------------*/
  76.  
  77.  
  78.     var $databaseType = 'oci8po';
  79.     
  80.     function ADORecordset_oci8po($queryID,$mode=false)
  81.     {
  82.         $this->ADORecordset_oci8($queryID,$mode);
  83.     }
  84.  
  85.     function Fields($colname)
  86.     {
  87.         if ($this->fetchMode OCI_ASSOCreturn $this->fields[$colname];
  88.         
  89.         if (!$this->bind{
  90.             $this->bind = array();
  91.             for ($i=0$i $this->_numOfFields$i++{
  92.                 $o $this->FetchField($i);
  93.                 $this->bind[strtoupper($o->name)$i;
  94.             }
  95.         }
  96.          return $this->fields[$this->bind[strtoupper($colname)]];
  97.     }
  98.     
  99.     // lowercase field names...
  100.     function &_FetchField($fieldOffset = -1)
  101.     {
  102.          $fld new ADOFieldObject;
  103.           $fieldOffset += 1;
  104.          $fld->name strtolower(OCIcolumnname($this->_queryID$fieldOffset));
  105.          $fld->type OCIcolumntype($this->_queryID$fieldOffset);
  106.          $fld->max_length OCIcolumnsize($this->_queryID$fieldOffset);
  107.          if ($fld->type == 'NUMBER'{
  108.              //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
  109.             $sc OCIColumnScale($this->_queryID$fieldOffset);
  110.             if ($sc == 0$fld->type 'INT';
  111.          }
  112.          return $fld;
  113.     }
  114.     /*
  115.     function MoveNext()
  116.     {
  117.         if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
  118.             $this->_currentRow += 1;
  119.             return true;
  120.         }
  121.         if (!$this->EOF) {
  122.             $this->_currentRow += 1;
  123.             $this->EOF = true;
  124.         }
  125.         return false;
  126.     }*/
  127.  
  128.     // 10% speedup to move MoveNext to child class
  129.     function MoveNext(
  130.     {
  131.         if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
  132.         global $ADODB_ANSI_PADDING_OFF;
  133.             $this->_currentRow++;
  134.             
  135.             if ($this->fetchMode OCI_ASSOC$this->_updatefields();
  136.             if (!empty($ADODB_ANSI_PADDING_OFF)) {
  137.                 foreach($this->fields as $k => $v{
  138.                     if (is_string($v)) $this->fields[$krtrim($v);
  139.                 }
  140.             }
  141.             return true;
  142.         }
  143.         if (!$this->EOF{
  144.             $this->EOF = true;
  145.             $this->_currentRow++;
  146.         }
  147.         return false;
  148.     }    
  149.     
  150.     /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
  151.     function &GetArrayLimit($nrows,$offset=-1
  152.     {
  153.         if ($offset <= 0{
  154.             $arr $this->GetArray($nrows);
  155.             return $arr;
  156.         }
  157.         for ($i=1$i $offset$i++
  158.             if (!@OCIFetch($this->_queryID)) {
  159.                 $arr array();
  160.                 return $arr;
  161.             }
  162.         if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
  163.             $arr array();
  164.             return $arr;
  165.         }
  166.         if ($this->fetchMode OCI_ASSOC$this->_updatefields();
  167.         $results array();
  168.         $cnt 0;
  169.         while (!$this->EOF && $nrows != $cnt{
  170.             $results[$cnt++$this->fields;
  171.             $this->MoveNext();
  172.         }
  173.         
  174.         return $results;
  175.     }
  176.  
  177.     // Create associative array
  178.     function _updatefields()
  179.     {
  180.         if (ADODB_ASSOC_CASE == 2return// native
  181.     
  182.         $arr array();
  183.         $lowercase (ADODB_ASSOC_CASE == 0);
  184.         
  185.         foreach($this->fields as $k => $v{
  186.             if (is_integer($k)) $arr[$k$v;
  187.             else {
  188.                 if ($lowercase)
  189.                     $arr[strtolower($k)$v;
  190.                 else
  191.                     $arr[strtoupper($k)$v;
  192.             }
  193.         }
  194.         $this->fields = $arr;
  195.     }
  196.     
  197.     function _fetch(
  198.     {
  199.         $ret @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
  200.         if ($ret{
  201.         global $ADODB_ANSI_PADDING_OFF;
  202.     
  203.                 if ($this->fetchMode OCI_ASSOC$this->_updatefields();
  204.                 if (!empty($ADODB_ANSI_PADDING_OFF)) {
  205.                     foreach($this->fields as $k => $v{
  206.                         if (is_string($v)) $this->fields[$krtrim($v);
  207.                     }
  208.                 }
  209.         }
  210.         return $ret;
  211.     }
  212.     
  213. }
  214.  
  215.  
  216. ?>

Documentation generated on Fri, 18 Jul 2008 21:40:35 +0200 by phpDocumentor 1.4.1