adodb 최신버전으로 변경
<? 를 <?php 로 변경
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). 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.
|
||||
/*
|
||||
@version v5.20.9 21-Dec-2016
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). 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.
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
|
||||
Latest version is available at http://adodb.sourceforge.net
|
||||
|
||||
|
||||
DB2 data driver. Requires ODBC.
|
||||
|
||||
|
||||
From phpdb list:
|
||||
|
||||
Hi Andrew,
|
||||
@@ -40,18 +42,18 @@ Kind regards,
|
||||
Christian Szardenings
|
||||
|
||||
2 Oct 2001
|
||||
Mark Newnham has discovered that the SQL_CUR_USE_ODBC is not supported by
|
||||
Mark Newnham has discovered that the SQL_CUR_USE_ODBC is not supported by
|
||||
IBM's DB2 ODBC driver, so this must be a 3rd party ODBC driver.
|
||||
|
||||
From the IBM CLI Reference:
|
||||
|
||||
SQL_ATTR_ODBC_CURSORS (DB2 CLI v5)
|
||||
SQL_ATTR_ODBC_CURSORS (DB2 CLI v5)
|
||||
This connection attribute is defined by ODBC, but is not supported by DB2
|
||||
CLI. Any attempt to set or get this attribute will result in an SQLSTATE of
|
||||
HYC00 (Driver not capable).
|
||||
HYC00 (Driver not capable).
|
||||
|
||||
A 32-bit option specifying how the Driver Manager uses the ODBC cursor
|
||||
library.
|
||||
library.
|
||||
|
||||
So I guess this means the message [above] was related to using a 3rd party
|
||||
odbc driver.
|
||||
@@ -69,15 +71,15 @@ $db->Connect($dsn, $userid, $pwd);
|
||||
USING CLI INTERFACE
|
||||
===================
|
||||
|
||||
I have had reports that the $host and $database params have to be reversed in
|
||||
I have had reports that the $host and $database params have to be reversed in
|
||||
Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu:
|
||||
|
||||
> The symptom is that if I change the database engine from postgres or any other to DB2 then the following
|
||||
> connection command becomes wrong despite being described this version to be correct in the docs.
|
||||
> connection command becomes wrong despite being described this version to be correct in the docs.
|
||||
>
|
||||
> $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME )
|
||||
>
|
||||
> In case of DB2 I had to swap the first and last arguments in order to connect properly.
|
||||
> In case of DB2 I had to swap the first and last arguments in order to connect properly.
|
||||
|
||||
|
||||
System Error 5
|
||||
@@ -96,12 +98,12 @@ if (!defined('ADODB_ODBC_DB2')){
|
||||
define('ADODB_ODBC_DB2',1);
|
||||
|
||||
class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
var $databaseType = "db2";
|
||||
var $databaseType = "db2";
|
||||
var $concat_operator = '||';
|
||||
var $sysTime = 'CURRENT TIME';
|
||||
var $sysDate = 'CURRENT DATE';
|
||||
var $sysTimeStamp = 'CURRENT TIMESTAMP';
|
||||
// The complete string representation of a timestamp has the form
|
||||
// The complete string representation of a timestamp has the form
|
||||
// yyyy-mm-dd-hh.mm.ss.nnnnnn.
|
||||
var $fmtTimeStamp = "'Y-m-d-H.i.s'";
|
||||
var $ansiOuter = true;
|
||||
@@ -109,18 +111,18 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
var $_bindInputArray = true;
|
||||
var $hasInsertID = true;
|
||||
var $rsPrefix = 'ADORecordset_odbc_';
|
||||
|
||||
function ADODB_DB2()
|
||||
|
||||
function __construct()
|
||||
{
|
||||
if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC;
|
||||
$this->ADODB_odbc();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function IfNull( $field, $ifNull )
|
||||
|
||||
function IfNull( $field, $ifNull )
|
||||
{
|
||||
return " COALESCE($field, $ifNull) "; // if DB2 UDB
|
||||
}
|
||||
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
//odbc_setoption($this->_connectionID,1,101 /*SQL_ATTR_ACCESS_MODE*/, 1 /*SQL_MODE_READ_ONLY*/);
|
||||
@@ -128,54 +130,54 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
//odbc_setoption($this->_connectionID,1,101, 0 /*SQL_MODE_READ_WRITE*/);
|
||||
return array('description'=>'DB2 ODBC driver', 'version'=>$vers);
|
||||
}
|
||||
|
||||
|
||||
function _insertid()
|
||||
{
|
||||
return $this->GetOne($this->identitySQL);
|
||||
}
|
||||
|
||||
function RowLock($tables,$where,$flds='1 as ignore')
|
||||
|
||||
function RowLock($tables,$where,$col='1 as adodbignore')
|
||||
{
|
||||
if ($this->_autocommit) $this->BeginTrans();
|
||||
return $this->GetOne("select $flds from $tables where $where for update");
|
||||
return $this->GetOne("select $col from $tables where $where for update");
|
||||
}
|
||||
|
||||
|
||||
function MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
|
||||
$savem = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
$qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, "");
|
||||
|
||||
|
||||
$rs = new ADORecordSet_odbc($qid);
|
||||
|
||||
|
||||
$ADODB_FETCH_MODE = $savem;
|
||||
if (!$rs) {
|
||||
$false = false;
|
||||
return $false;
|
||||
}
|
||||
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
|
||||
|
||||
|
||||
$arr = $rs->GetArray();
|
||||
//print_r($arr);
|
||||
|
||||
|
||||
$rs->Close();
|
||||
$arr2 = array();
|
||||
|
||||
|
||||
if ($ttype) {
|
||||
$isview = strncmp($ttype,'V',1) === 0;
|
||||
}
|
||||
for ($i=0; $i < sizeof($arr); $i++) {
|
||||
|
||||
|
||||
if (!$arr[$i][2]) continue;
|
||||
if (strncmp($arr[$i][1],'SYS',3) === 0) continue;
|
||||
|
||||
|
||||
$type = $arr[$i][3];
|
||||
|
||||
|
||||
if ($showSchema) $arr[$i][2] = $arr[$i][1].'.'.$arr[$i][2];
|
||||
|
||||
if ($ttype) {
|
||||
|
||||
if ($ttype) {
|
||||
if ($isview) {
|
||||
if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2];
|
||||
} else if (strncmp($type,'T',1) === 0) $arr2[] = $arr[$i][2];
|
||||
@@ -197,11 +199,11 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
// get index details
|
||||
$table = strtoupper($table);
|
||||
$SQL="SELECT NAME, UNIQUERULE, COLNAMES FROM SYSIBM.SYSINDEXES WHERE TBNAME='$table'";
|
||||
if ($primary)
|
||||
if ($primary)
|
||||
$SQL.= " AND UNIQUERULE='P'";
|
||||
$rs = $this->Execute($SQL);
|
||||
if (!is_object($rs)) {
|
||||
if (isset($savem))
|
||||
if (isset($savem))
|
||||
$this->SetFetchMode($savem);
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
@@ -216,20 +218,20 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
$cols = ltrim($row[2],'+');
|
||||
$indexes[$row[0]]['columns'] = explode('+', $cols);
|
||||
}
|
||||
if (isset($savem)) {
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
}
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
|
||||
// Format date column in sql string given an input format that understands Y M D
|
||||
function SQLDate($fmt, $col=false)
|
||||
{
|
||||
{
|
||||
// use right() and replace() ?
|
||||
if (!$col) $col = $this->sysDate;
|
||||
$s = '';
|
||||
|
||||
|
||||
$len = strlen($fmt);
|
||||
for ($i=0; $i < $len; $i++) {
|
||||
if ($s) $s .= '||';
|
||||
@@ -251,7 +253,7 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
break;
|
||||
case 'H':
|
||||
case 'h':
|
||||
if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)";
|
||||
if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)";
|
||||
else $s .= "''";
|
||||
break;
|
||||
case 'i':
|
||||
@@ -275,10 +277,10 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
}
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
||||
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false)
|
||||
}
|
||||
|
||||
|
||||
function SelectLimit($sql, $nrows = -1, $offset = -1, $inputArr = false, $secs2cache = 0)
|
||||
{
|
||||
$nrows = (integer) $nrows;
|
||||
if ($offset <= 0) {
|
||||
@@ -293,20 +295,20 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
}
|
||||
$rs = ADOConnection::SelectLimit($sql,-1,$offset,$inputArr);
|
||||
}
|
||||
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = "db2";
|
||||
|
||||
function ADORecordSet_db2($id,$mode=false)
|
||||
};
|
||||
|
||||
|
||||
class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = "db2";
|
||||
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_odbc($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
@@ -316,53 +318,52 @@ class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
|
||||
|
||||
switch (strtoupper($t)) {
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
case 'CHARACTER':
|
||||
case 'C':
|
||||
if ($len <= $this->blobSize) return 'C';
|
||||
|
||||
|
||||
case 'LONGCHAR':
|
||||
case 'TEXT':
|
||||
case 'CLOB':
|
||||
case 'DBCLOB': // double-byte
|
||||
case 'X':
|
||||
return 'X';
|
||||
|
||||
|
||||
case 'BLOB':
|
||||
case 'GRAPHIC':
|
||||
case 'VARGRAPHIC':
|
||||
return 'B';
|
||||
|
||||
|
||||
case 'DATE':
|
||||
case 'D':
|
||||
return 'D';
|
||||
|
||||
|
||||
case 'TIME':
|
||||
case 'TIMESTAMP':
|
||||
case 'T':
|
||||
return 'T';
|
||||
|
||||
//case 'BOOLEAN':
|
||||
|
||||
//case 'BOOLEAN':
|
||||
//case 'BIT':
|
||||
// return 'L';
|
||||
|
||||
|
||||
//case 'COUNTER':
|
||||
// return 'R';
|
||||
|
||||
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
case 'SMALLINT':
|
||||
case 'I':
|
||||
return 'I';
|
||||
|
||||
|
||||
default: return 'N';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //define
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user