adodb 최신버전으로 변경

<? 를 <?php 로 변경
This commit is contained in:
2018-01-11 19:28:35 +09:00
parent feff33715f
commit 7b3b674dee
450 changed files with 19425 additions and 32248 deletions
+102 -93
View File
@@ -1,12 +1,14 @@
<?php
/*
V5.09 25 June 2009 (c) 2000-2009 John Lim. All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
@version v5.20.9 21-Dec-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
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://adodb.sourceforge.net
Portable version of oci8 driver, to make it more similar to other database drivers.
The main differences are
@@ -14,7 +16,7 @@ V5.09 25 June 2009 (c) 2000-2009 John Lim. All rights reserved.
2. bind variables are mapped using ? instead of :<bindvar>
Should some emulation of RecordCount() be implemented?
*/
// security - hide paths
@@ -27,28 +29,48 @@ class ADODB_oci8po extends ADODB_oci8 {
var $dataProvider = 'oci8';
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
var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')";
function ADODB_oci8po()
function __construct()
{
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
# oci8po does not support adodb extension: adodb_movenext()
}
function Param($name)
function Param($name,$type='C')
{
return '?';
}
function Prepare($sql,$cursor=false)
{
$sqlarr = explode('?',$sql);
$sql = $sqlarr[0];
for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
$sql .= ':'.($i-1) . $sqlarr[$i];
}
}
return ADODB_oci8::Prepare($sql,$cursor);
}
function Execute($sql,$inputarr=false)
{
return ADOConnection::Execute($sql,$inputarr);
}
/**
* The optimizations performed by ADODB_oci8::SelectLimit() are not
* compatible with the oci8po driver, so we rely on the slower method
* from the base class.
* We can't properly handle prepared statements either due to preprocessing
* of query parameters, so we treat them as regular SQL statements.
*/
function SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0)
{
if(is_array($sql)) {
// $sql = $sql[0];
}
return ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
}
// emulate handling of parameters ? ?, replacing with :bind0 :bind1
function _query($sql,$inputarr=false)
{
@@ -57,13 +79,27 @@ class ADODB_oci8po extends ADODB_oci8 {
if (is_array($sql)) {
foreach($inputarr as $v) {
$arr['bind'.$i++] = $v;
}
} else {
$sqlarr = explode('?',$sql);
$sql = $sqlarr[0];
foreach($inputarr as $k => $v) {
$sql .= ":$k" . $sqlarr[++$i];
}
} else {
// Need to identify if the ? is inside a quoted string, and if
// so not use it as a bind variable
preg_match_all('/".*\??"|\'.*\?.*?\'/', $sql, $matches);
foreach($matches[0] as $qmMatch){
$qmReplace = str_replace('?', '-QUESTIONMARK-', $qmMatch);
$sql = str_replace($qmMatch, $qmReplace, $sql);
}
// Replace parameters if any were found
$sqlarr = explode('?',$sql);
if(count($sqlarr) > 1) {
$sql = $sqlarr[0];
foreach ($inputarr as $k => $v) {
$sql .= ":$k" . $sqlarr[++$i];
}
}
$sql = str_replace('-QUESTIONMARK-', '?', $sql);
}
}
return ADODB_oci8::_query($sql,$inputarr);
@@ -77,16 +113,16 @@ class ADODB_oci8po extends ADODB_oci8 {
class ADORecordset_oci8po extends ADORecordset_oci8 {
var $databaseType = 'oci8po';
function ADORecordset_oci8po($queryID,$mode=false)
function __construct($queryID,$mode=false)
{
$this->ADORecordset_oci8($queryID,$mode);
parent::__construct($queryID,$mode);
}
function Fields($colname)
{
if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
if (!$this->bind) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
@@ -96,45 +132,37 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
}
return $this->fields[$this->bind[strtoupper($colname)]];
}
// lowercase field names...
function _FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$fieldOffset += 1;
$fld->name = OCIcolumnname($this->_queryID, $fieldOffset);
if (ADODB_ASSOC_CASE == 0) $fld->name = strtolower($fld->name);
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') {
//$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
$fld = new ADOFieldObject;
$fieldOffset += 1;
$fld->name = OCIcolumnname($this->_queryID, $fieldOffset);
if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER) {
$fld->name = strtolower($fld->name);
}
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') {
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
if ($sc == 0) $fld->type = 'INT';
}
return $fld;
if ($sc == 0) {
$fld->type = 'INT';
}
}
return $fld;
}
/*
function MoveNext()
{
if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
$this->_currentRow += 1;
return true;
}
if (!$this->EOF) {
$this->_currentRow += 1;
$this->EOF = true;
}
return false;
}*/
// 10% speedup to move MoveNext to child class
function MoveNext()
function MoveNext()
{
if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
if($ret !== false) {
global $ADODB_ANSI_PADDING_OFF;
$this->fields = $ret;
$this->_currentRow++;
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
$this->_updatefields();
if (!empty($ADODB_ANSI_PADDING_OFF)) {
foreach($this->fields as $k => $v) {
if (is_string($v)) $this->fields[$k] = rtrim($v);
@@ -147,72 +175,53 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
$this->_currentRow++;
}
return false;
}
}
/* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
function GetArrayLimit($nrows,$offset=-1)
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) {
$arr = $this->GetArray($nrows);
return $arr;
}
for ($i=1; $i < $offset; $i++)
for ($i=1; $i < $offset; $i++)
if (!@OCIFetch($this->_queryID)) {
$arr = array();
return $arr;
}
if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
if ($ret === false) {
$arr = array();
return $arr;
}
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
$this->fields = $ret;
$this->_updatefields();
$results = array();
$cnt = 0;
while (!$this->EOF && $nrows != $cnt) {
$results[$cnt++] = $this->fields;
$this->MoveNext();
}
return $results;
}
// Create associative array
function _updatefields()
function _fetch()
{
if (ADODB_ASSOC_CASE == 2) return; // native
$arr = array();
$lowercase = (ADODB_ASSOC_CASE == 0);
foreach($this->fields as $k => $v) {
if (is_integer($k)) $arr[$k] = $v;
else {
if ($lowercase)
$arr[strtolower($k)] = $v;
else
$arr[strtoupper($k)] = $v;
global $ADODB_ANSI_PADDING_OFF;
$ret = @oci_fetch_array($this->_queryID,$this->fetchMode);
if ($ret) {
$this->fields = $ret;
$this->_updatefields();
if (!empty($ADODB_ANSI_PADDING_OFF)) {
foreach($this->fields as $k => $v) {
if (is_string($v)) $this->fields[$k] = rtrim($v);
}
}
}
$this->fields = $arr;
return $ret !== false;
}
function _fetch()
{
$ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
if ($ret) {
global $ADODB_ANSI_PADDING_OFF;
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
if (!empty($ADODB_ANSI_PADDING_OFF)) {
foreach($this->fields as $k => $v) {
if (is_string($v)) $this->fields[$k] = rtrim($v);
}
}
}
return $ret;
}
}
?>