MDL-9876 import adodb 4.95a
This commit is contained in:
@@ -18,10 +18,11 @@
|
||||
|
||||
global $_ADODB_ACTIVE_DBS;
|
||||
global $ADODB_ACTIVE_CACHESECS; // set to true to enable caching of metadata such as field info
|
||||
global $ACTIVE_RECORD_SAFETY; // set to false to disable safety checks
|
||||
|
||||
// array of ADODB_Active_DB's, indexed by ADODB_Active_Record->_dbat
|
||||
$_ADODB_ACTIVE_DBS = array();
|
||||
|
||||
$ACTIVE_RECORD_SAFETY = true;
|
||||
|
||||
class ADODB_Active_DB {
|
||||
var $db; // ADOConnection
|
||||
@@ -322,6 +323,8 @@ class ADODB_Active_Record {
|
||||
// set a numeric array (using natural table field ordering) as object properties
|
||||
function Set(&$row)
|
||||
{
|
||||
global $ACTIVE_RECORD_SAFETY;
|
||||
|
||||
$db =& $this->DB();
|
||||
|
||||
if (!$row) {
|
||||
@@ -332,7 +335,7 @@ class ADODB_Active_Record {
|
||||
$this->_saved = true;
|
||||
|
||||
$table =& $this->TableInfo();
|
||||
if (sizeof($table->flds) != sizeof($row)) {
|
||||
if ($ACTIVE_RECORD_SAFETY && sizeof($table->flds) != sizeof($row)) {
|
||||
$this->Error("Table structure of $this->_table has changed","Load");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -215,9 +215,117 @@ class ADODB_DataDict {
|
||||
return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner);
|
||||
}
|
||||
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
return ADORecordSet::MetaType($t,$len,$fieldobj);
|
||||
{
|
||||
static $typeMap = array(
|
||||
'VARCHAR' => 'C',
|
||||
'VARCHAR2' => 'C',
|
||||
'CHAR' => 'C',
|
||||
'C' => 'C',
|
||||
'STRING' => 'C',
|
||||
'NCHAR' => 'C',
|
||||
'NVARCHAR' => 'C',
|
||||
'VARYING' => 'C',
|
||||
'BPCHAR' => 'C',
|
||||
'CHARACTER' => 'C',
|
||||
'INTERVAL' => 'C', # Postgres
|
||||
'MACADDR' => 'C', # postgres
|
||||
##
|
||||
'LONGCHAR' => 'X',
|
||||
'TEXT' => 'X',
|
||||
'NTEXT' => 'X',
|
||||
'M' => 'X',
|
||||
'X' => 'X',
|
||||
'CLOB' => 'X',
|
||||
'NCLOB' => 'X',
|
||||
'LVARCHAR' => 'X',
|
||||
##
|
||||
'BLOB' => 'B',
|
||||
'IMAGE' => 'B',
|
||||
'BINARY' => 'B',
|
||||
'VARBINARY' => 'B',
|
||||
'LONGBINARY' => 'B',
|
||||
'B' => 'B',
|
||||
##
|
||||
'YEAR' => 'D', // mysql
|
||||
'DATE' => 'D',
|
||||
'D' => 'D',
|
||||
##
|
||||
'UNIQUEIDENTIFIER' => 'C', # MS SQL Server
|
||||
##
|
||||
'TIME' => 'T',
|
||||
'TIMESTAMP' => 'T',
|
||||
'DATETIME' => 'T',
|
||||
'TIMESTAMPTZ' => 'T',
|
||||
'T' => 'T',
|
||||
'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql
|
||||
##
|
||||
'BOOL' => 'L',
|
||||
'BOOLEAN' => 'L',
|
||||
'BIT' => 'L',
|
||||
'L' => 'L',
|
||||
##
|
||||
'COUNTER' => 'R',
|
||||
'R' => 'R',
|
||||
'SERIAL' => 'R', // ifx
|
||||
'INT IDENTITY' => 'R',
|
||||
##
|
||||
'INT' => 'I',
|
||||
'INT2' => 'I',
|
||||
'INT4' => 'I',
|
||||
'INT8' => 'I',
|
||||
'INTEGER' => 'I',
|
||||
'INTEGER UNSIGNED' => 'I',
|
||||
'SHORT' => 'I',
|
||||
'TINYINT' => 'I',
|
||||
'SMALLINT' => 'I',
|
||||
'I' => 'I',
|
||||
##
|
||||
'LONG' => 'N', // interbase is numeric, oci8 is blob
|
||||
'BIGINT' => 'N', // this is bigger than PHP 32-bit integers
|
||||
'DECIMAL' => 'N',
|
||||
'DEC' => 'N',
|
||||
'REAL' => 'N',
|
||||
'DOUBLE' => 'N',
|
||||
'DOUBLE PRECISION' => 'N',
|
||||
'SMALLFLOAT' => 'N',
|
||||
'FLOAT' => 'N',
|
||||
'NUMBER' => 'N',
|
||||
'NUM' => 'N',
|
||||
'NUMERIC' => 'N',
|
||||
'MONEY' => 'N',
|
||||
|
||||
## informix 9.2
|
||||
'SQLINT' => 'I',
|
||||
'SQLSERIAL' => 'I',
|
||||
'SQLSMINT' => 'I',
|
||||
'SQLSMFLOAT' => 'N',
|
||||
'SQLFLOAT' => 'N',
|
||||
'SQLMONEY' => 'N',
|
||||
'SQLDECIMAL' => 'N',
|
||||
'SQLDATE' => 'D',
|
||||
'SQLVCHAR' => 'C',
|
||||
'SQLCHAR' => 'C',
|
||||
'SQLDTIME' => 'T',
|
||||
'SQLINTERVAL' => 'N',
|
||||
'SQLBYTES' => 'B',
|
||||
'SQLTEXT' => 'X',
|
||||
## informix 10
|
||||
"SQLINT8" => 'I8',
|
||||
"SQLSERIAL8" => 'I8',
|
||||
"SQLNCHAR" => 'C',
|
||||
"SQLNVCHAR" => 'C',
|
||||
"SQLLVARCHAR" => 'X',
|
||||
"SQLBOOL" => 'L'
|
||||
);
|
||||
|
||||
if (!$this->connection->IsConnected()) {
|
||||
$t = strtoupper($t);
|
||||
if (isset($typeMap[$t])) return $typeMap[$t];
|
||||
return 'N';
|
||||
}
|
||||
return $this->connection->MetaType($t,$len,$fieldobj);
|
||||
}
|
||||
|
||||
function NameQuote($name = NULL,$allowBrackets=false)
|
||||
|
||||
@@ -968,24 +968,26 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
|
||||
$val = $zthis->DBDate($arrFields[$fname]);
|
||||
break;
|
||||
|
||||
case "T":
|
||||
|
||||
case "T":
|
||||
$val = $zthis->DBTimeStamp($arrFields[$fname]);
|
||||
break;
|
||||
|
||||
// moodle change start - see readme_moodle.txt
|
||||
case "L": //Integer field suitable for storing booleans (0 or 1)
|
||||
case "I": //Integer
|
||||
$val = (int)$arrFields[$fname];
|
||||
break;
|
||||
|
||||
case "F": //Floating point number
|
||||
case "N": //Numeric or decimal number
|
||||
$val = (float)$arrFields[$fname];
|
||||
break;
|
||||
// moodle change end
|
||||
|
||||
default:
|
||||
$val = $arrFields[$fname];
|
||||
case "L": //Integer field suitable for storing booleans (0 or 1)
|
||||
// moodle change end
|
||||
case "I":
|
||||
case "R":
|
||||
$val = (int) $arrFields[$fname];
|
||||
break;
|
||||
|
||||
default:
|
||||
$val = str_replace(array("'"," ","("),"",$arrFields[$fname]); // basic sql injection defence
|
||||
if (empty($val)) $val = '0';
|
||||
break;
|
||||
}
|
||||
|
||||
+10
-10
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Set tabs to 4 for best viewing.
|
||||
*
|
||||
* Latest version is available at http://adodb.sourceforge.net
|
||||
* Latest version is available at http://adodb.sourceforge.net/
|
||||
*
|
||||
* This is the main include file for ADOdb.
|
||||
* Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php
|
||||
@@ -1576,7 +1576,7 @@
|
||||
$dir = $ADODB_CACHE_DIR;
|
||||
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp( "CacheFlush: $dir<br><pre>\n", $this->_dirFlush($dir),"</pre>");
|
||||
ADOConnection::outp( "CacheFlush: $dir<br><pre>\n". $this->_dirFlush($dir)."</pre>");
|
||||
} else {
|
||||
$this->_dirFlush($dir);
|
||||
}
|
||||
@@ -1599,18 +1599,18 @@
|
||||
* Just specify the directory, and tell it if you want to delete the directory or just clear it out.
|
||||
* Note: $kill_top_level is used internally in the function to flush subdirectories.
|
||||
*/
|
||||
function _dirFlush($dir, $kill_top_level = false) {
|
||||
function _dirFlush($dir, $kill_top_level = false)
|
||||
{
|
||||
if(!$dh = @opendir($dir)) return;
|
||||
|
||||
while (($obj = readdir($dh))) {
|
||||
if($obj=='.' || $obj=='..')
|
||||
continue;
|
||||
|
||||
if (!@unlink($dir.'/'.$obj))
|
||||
$this->_dirFlush($dir.'/'.$obj, true);
|
||||
if($obj=='.' || $obj=='..') continue;
|
||||
$f = $dir.'/'.$obj;
|
||||
|
||||
if (strpos($obj,'.cache')) @unlink($f);
|
||||
if (is_dir($f)) $this->_dirFlush($f, true);
|
||||
}
|
||||
if ($kill_top_level === true)
|
||||
@rmdir($dir);
|
||||
if ($kill_top_level === true) @rmdir($dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,6 @@ class ADODB_ado extends ADOConnection {
|
||||
|
||||
if ($argProvider) $dbc->Provider = $argProvider;
|
||||
|
||||
if ($argProvider) $argHostname = "PROVIDER=$argProvider;DRIVER={SQL Server};SERVER=$argHostname";
|
||||
|
||||
|
||||
if ($argDatabasename) $argHostname .= ";DATABASE=$argDatabasename";
|
||||
if ($argUsername) $argHostname .= ";$u=$argUsername";
|
||||
if ($argPassword)$argHostname .= ";$p=$argPassword";
|
||||
|
||||
@@ -33,7 +33,7 @@ class ADODB_db2 extends ADOConnection {
|
||||
var $sysDate = 'CURRENT DATE';
|
||||
var $sysTimeStamp = 'CURRENT TIMESTAMP';
|
||||
|
||||
var $fmtTimeStamp = "'Y-m-d-H.i.s'";
|
||||
var $fmtTimeStamp = "'Y-m-d-H:i:s'";
|
||||
var $replaceQuote = "''"; // string to use to replace quotes
|
||||
var $dataProvider = "db2";
|
||||
var $hasAffectedRows = true;
|
||||
|
||||
@@ -184,6 +184,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
// Reference on Last_Insert_ID on the recommended way to simulate sequences
|
||||
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
|
||||
var $_genSeqSQL = "create table %s (id int not null)";
|
||||
var $_genSeqCountSQL = "select count(*) from %s";
|
||||
var $_genSeq2SQL = "insert into %s values (%s)";
|
||||
var $_dropSeqSQL = "drop table %s";
|
||||
|
||||
@@ -212,12 +213,16 @@ class ADODB_mysql extends ADOConnection {
|
||||
if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
|
||||
$u = strtoupper($seqname);
|
||||
$this->Execute(sprintf($this->_genSeqSQL,$seqname));
|
||||
$this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
|
||||
$cnt = $this->GetOne(sprintf($this->_genSeqCountSQL,$seqname));
|
||||
if (!$cnt) $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
|
||||
$rs = $this->Execute($getnext);
|
||||
}
|
||||
$this->genID = mysql_insert_id($this->_connectionID);
|
||||
|
||||
if ($rs) $rs->Close();
|
||||
if ($rs) {
|
||||
$this->genID = mysql_insert_id($this->_connectionID);
|
||||
$rs->Close();
|
||||
} else
|
||||
$this->genID = 0;
|
||||
|
||||
$this->_logsql = $savelog;
|
||||
return $this->genID;
|
||||
@@ -442,8 +447,9 @@ class ADODB_mysql extends ADOConnection {
|
||||
$fld->primary_key = ($rs->fields[3] == 'PRI');
|
||||
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
|
||||
$fld->binary = (strpos($type,'blob') !== false);
|
||||
$fld->unsigned = (strpos($type,'unsigned') !== false);
|
||||
|
||||
$fld->unsigned = (strpos($type,'unsigned') !== false);
|
||||
$fld->zerofill = (strpos($type,'zerofill') !== false);
|
||||
|
||||
if (!$fld->binary) {
|
||||
$d = $rs->fields[4];
|
||||
if ($d != '' && $d != 'NULL') {
|
||||
|
||||
@@ -273,13 +273,17 @@ class ADODB_mysqli extends ADOConnection {
|
||||
if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
|
||||
$u = strtoupper($seqname);
|
||||
$this->Execute(sprintf($this->_genSeqSQL,$seqname));
|
||||
$this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
|
||||
$cnt = $this->GetOne(sprintf($this->_genSeqCountSQL,$seqname));
|
||||
if (!$cnt) $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
|
||||
$rs = $this->Execute($getnext);
|
||||
}
|
||||
$this->genID = mysqli_insert_id($this->_connectionID);
|
||||
|
||||
if ($rs) $rs->Close();
|
||||
|
||||
if ($rs) {
|
||||
$this->genID = mysqli_insert_id($this->_connectionID);
|
||||
$rs->Close();
|
||||
} else
|
||||
$this->genID = 0;
|
||||
|
||||
return $this->genID;
|
||||
}
|
||||
|
||||
@@ -559,6 +563,7 @@ class ADODB_mysqli extends ADOConnection {
|
||||
$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
|
||||
$fld->binary = (strpos($type,'blob') !== false);
|
||||
$fld->unsigned = (strpos($type,'unsigned') !== false);
|
||||
$fld->zerofill = (strpos($type,'zerofill') !== false);
|
||||
|
||||
if (!$fld->binary) {
|
||||
$d = $rs->fields[4];
|
||||
|
||||
@@ -83,6 +83,7 @@ class ADODB_oci8 extends ADOConnection {
|
||||
var $firstrows = true; // enable first rows optimization on SelectLimit()
|
||||
var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit.
|
||||
var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
|
||||
var $dateformat = 'YYYY-MM-DD'; // for DBDate()
|
||||
var $useDBDateFormatForTextInput=false;
|
||||
var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true)
|
||||
var $_refLOBs = array();
|
||||
@@ -276,7 +277,7 @@ NATSOFT.DOMAIN =
|
||||
if (empty($d) && $d !== 0) return 'null';
|
||||
|
||||
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
|
||||
return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->NLS_DATE_FORMAT."')";
|
||||
return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->dateformat."')";
|
||||
}
|
||||
|
||||
function BindDate($d)
|
||||
@@ -300,7 +301,7 @@ NATSOFT.DOMAIN =
|
||||
{
|
||||
if (empty($ts) && $ts !== 0) return 'null';
|
||||
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
|
||||
return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')";
|
||||
return 'TO_DATE('.adodb_date("'Y-m-d H:i:s'",$ts).",'RRRR-MM-DD, HH24:MI:SS')";
|
||||
}
|
||||
|
||||
function RowLock($tables,$where,$flds='1 as ignore')
|
||||
|
||||
@@ -150,7 +150,7 @@ class ADODB_oracle extends ADOConnection {
|
||||
if ($argDatabasename) $argUsername .= "@$argDatabasename";
|
||||
|
||||
//if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
|
||||
if ($mode = 1)
|
||||
if ($mode == 1)
|
||||
$this->_connectionID = ora_plogon($argUsername,$argPassword);
|
||||
else
|
||||
$this->_connectionID = ora_logon($argUsername,$argPassword);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// by Trirat Petchsingh <rosskouk#gmail.com>
|
||||
$ADODB_LANG_ARRAY = array (
|
||||
'LANG' => 'th',
|
||||
DB_ERROR => 'error ไม่รู้สาเหตุ',
|
||||
DB_ERROR_ALREADY_EXISTS => 'มี�ล้ว',
|
||||
DB_ERROR_CANNOT_CREATE => 'สร้างไม่ได้',
|
||||
DB_ERROR_CANNOT_DELETE => 'ลบไม่ได้',
|
||||
DB_ERROR_CANNOT_DROP => 'drop ไม่ได้',
|
||||
DB_ERROR_CONSTRAINT => 'constraint violation',
|
||||
DB_ERROR_DIVZERO => 'หา�ด้วยสู�',
|
||||
DB_ERROR_INVALID => 'ไม่ valid',
|
||||
DB_ERROR_INVALID_DATE => 'วันที่ เวลา ไม่ valid',
|
||||
DB_ERROR_INVALID_NUMBER => 'เลขไม่ valid',
|
||||
DB_ERROR_MISMATCH => 'mismatch',
|
||||
DB_ERROR_NODBSELECTED => 'ไม่ได้เลืà¸à¸?à¸?านข้à¸à¸¡à¸¹à¸¥',
|
||||
DB_ERROR_NOSUCHFIELD => 'ไม่มีฟีลด์นี้',
|
||||
DB_ERROR_NOSUCHTABLE => 'ไม่มีตารางนี้',
|
||||
DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
|
||||
DB_ERROR_NOT_FOUND => 'ไม่พบ',
|
||||
DB_ERROR_NOT_LOCKED => 'ไม่ได้ล๊à¸à¸?',
|
||||
DB_ERROR_SYNTAX => 'ผิด syntax',
|
||||
DB_ERROR_UNSUPPORTED => 'ไม่ support',
|
||||
DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row',
|
||||
DB_ERROR_INVALID_DSN => 'invalid DSN',
|
||||
DB_ERROR_CONNECT_FAILED => 'ไม่สามารถ connect',
|
||||
0 => 'no error', // DB_OK
|
||||
DB_ERROR_NEED_MORE_DATA => 'ข้à¸à¸¡à¸¹à¸¥à¹„ม่เพียงพà¸',
|
||||
DB_ERROR_EXTENSION_NOT_FOUND=> 'ไม่พบ extension',
|
||||
DB_ERROR_NOSUCHDB => 'ไม่มีข้à¸à¸¡à¸¹à¸¥à¸™à¸µà¹‰',
|
||||
DB_ERROR_ACCESS_VIOLATION => 'permissions ไม่พà¸'
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -109,8 +109,8 @@ AND b.name = 'sorts (memory)'",
|
||||
where name = 'free memory' and pool = 'shared pool'",
|
||||
'Percentage of data cache actually in use - should be over 85%'),
|
||||
|
||||
'shared pool utilization ratio' => array('RATIOU',
|
||||
'select round((sga.bytes/p.value)*100,2)
|
||||
'shared pool utilization ratio' => array('RATIOU',
|
||||
'select round((sga.bytes/case when p.value=0 then sga.bytes else to_number(p.value) end)*100,2)
|
||||
from v$sgastat sga, v$parameter p
|
||||
where sga.name = \'free memory\' and sga.pool = \'shared pool\'
|
||||
and p.name = \'shared_pool_size\'',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Description of ADODB v4.94 library import into Moodle
|
||||
Description of ADODB v4.95a library import into Moodle
|
||||
|
||||
Removed:
|
||||
* contrib/
|
||||
|
||||
@@ -443,8 +443,14 @@ class ADODB_Session {
|
||||
|
||||
/*!
|
||||
*/
|
||||
function &_conn($conn=null) {
|
||||
return $GLOBALS['ADODB_SESS_CONN'];
|
||||
function &_conn($conn=null)
|
||||
{
|
||||
if (isset($GLOBALS['ADODB_SESS_CONN'])) {
|
||||
$conn =& $GLOBALS['ADODB_SESS_CONN'];
|
||||
return $conn;
|
||||
}
|
||||
$false = false;
|
||||
return $false;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -768,7 +774,7 @@ class ADODB_Session {
|
||||
$rs =& $conn->Execute($sql,array($expireref,$key));
|
||||
|
||||
$qkey = $conn->qstr($key);
|
||||
$rs2 =& $conn->UpdateBlob($table, 'sessdata', $val, " sesskey=$qkey", strtoupper($clob));
|
||||
$rs2 = $conn->UpdateBlob($table, 'sessdata', $val, " sesskey=$qkey", strtoupper($clob));
|
||||
$rs = @$conn->CompleteTrans();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user