Merge branch 'wip-MDL-52286-m30' of https://github.com/marinaglancy/moodle into MOODLE_30_STABLE
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
|
||||
@version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
Latest version is available at http://adodb.sourceforge.net
|
||||
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
@@ -52,10 +54,13 @@ function ADODB_SetDatabaseAdapter(&$db, $index=false)
|
||||
|
||||
foreach($_ADODB_ACTIVE_DBS as $k => $d) {
|
||||
if (PHP_VERSION >= 5) {
|
||||
if ($d->db === $db) return $k;
|
||||
} else {
|
||||
if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database)
|
||||
if ($d->db === $db) {
|
||||
return $k;
|
||||
}
|
||||
} else {
|
||||
if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database) {
|
||||
return $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +68,9 @@ function ADODB_SetDatabaseAdapter(&$db, $index=false)
|
||||
$obj->db = $db;
|
||||
$obj->tables = array();
|
||||
|
||||
if ($index == false) $index = sizeof($_ADODB_ACTIVE_DBS);
|
||||
|
||||
if ($index == false) {
|
||||
$index = sizeof($_ADODB_ACTIVE_DBS);
|
||||
}
|
||||
|
||||
$_ADODB_ACTIVE_DBS[$index] = $obj;
|
||||
|
||||
@@ -92,7 +98,9 @@ class ADODB_Active_Record {
|
||||
static function UseDefaultValues($bool=null)
|
||||
{
|
||||
global $ADODB_ACTIVE_DEFVALS;
|
||||
if (isset($bool)) $ADODB_ACTIVE_DEFVALS = $bool;
|
||||
if (isset($bool)) {
|
||||
$ADODB_ACTIVE_DEFVALS = $bool;
|
||||
}
|
||||
return $ADODB_ACTIVE_DEFVALS;
|
||||
}
|
||||
|
||||
@@ -120,14 +128,21 @@ class ADODB_Active_Record {
|
||||
}
|
||||
|
||||
if (!$table) {
|
||||
if (!empty($this->_table)) $table = $this->_table;
|
||||
if (!empty($this->_table)) {
|
||||
$table = $this->_table;
|
||||
}
|
||||
else $table = $this->_pluralize(get_class($this));
|
||||
}
|
||||
$this->foreignName = strtolower(get_class($this)); // CFR: default foreign name
|
||||
if ($db) {
|
||||
$this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db);
|
||||
} else if (!isset($this->_dbat)) {
|
||||
if (sizeof($_ADODB_ACTIVE_DBS) == 0) $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)",'ADODB_Active_Record::__constructor');
|
||||
if (sizeof($_ADODB_ACTIVE_DBS) == 0) {
|
||||
$this->Error(
|
||||
"No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)",
|
||||
'ADODB_Active_Record::__constructor'
|
||||
);
|
||||
}
|
||||
end($_ADODB_ACTIVE_DBS);
|
||||
$this->_dbat = key($_ADODB_ACTIVE_DBS);
|
||||
}
|
||||
@@ -146,7 +161,9 @@ class ADODB_Active_Record {
|
||||
|
||||
function _pluralize($table)
|
||||
{
|
||||
if (!ADODB_Active_Record::$_changeNames) return $table;
|
||||
if (!ADODB_Active_Record::$_changeNames) {
|
||||
return $table;
|
||||
}
|
||||
|
||||
$ut = strtoupper($table);
|
||||
$len = strlen($table);
|
||||
@@ -160,8 +177,9 @@ class ADODB_Active_Record {
|
||||
case 'X':
|
||||
return $table.'es';
|
||||
case 'H':
|
||||
if ($lastc2 == 'CH' || $lastc2 == 'SH')
|
||||
if ($lastc2 == 'CH' || $lastc2 == 'SH') {
|
||||
return $table.'es';
|
||||
}
|
||||
default:
|
||||
return $table.'s';
|
||||
}
|
||||
@@ -172,24 +190,28 @@ class ADODB_Active_Record {
|
||||
function _singularize($tables)
|
||||
{
|
||||
|
||||
if (!ADODB_Active_Record::$_changeNames) return $table;
|
||||
if (!ADODB_Active_Record::$_changeNames) {
|
||||
return $table;
|
||||
}
|
||||
|
||||
$ut = strtoupper($tables);
|
||||
$len = strlen($tables);
|
||||
if($ut[$len-1] != 'S')
|
||||
if($ut[$len-1] != 'S') {
|
||||
return $tables; // I know...forget oxen
|
||||
if($ut[$len-2] != 'E')
|
||||
}
|
||||
if($ut[$len-2] != 'E') {
|
||||
return substr($tables, 0, $len-1);
|
||||
switch($ut[$len-3])
|
||||
{
|
||||
}
|
||||
switch($ut[$len-3]) {
|
||||
case 'S':
|
||||
case 'X':
|
||||
return substr($tables, 0, $len-2);
|
||||
case 'I':
|
||||
return substr($tables, 0, $len-3) . 'y';
|
||||
case 'H';
|
||||
if($ut[$len-4] == 'C' || $ut[$len-4] == 'S')
|
||||
if($ut[$len-4] == 'C' || $ut[$len-4] == 'S') {
|
||||
return substr($tables, 0, $len-2);
|
||||
}
|
||||
default:
|
||||
return substr($tables, 0, $len-1); // ?
|
||||
}
|
||||
@@ -216,7 +238,9 @@ class ADODB_Active_Record {
|
||||
// use when you don't want ADOdb to auto-pluralize tablename
|
||||
static function TableKeyHasMany($table, $tablePKey, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record')
|
||||
{
|
||||
if (!is_array($tablePKey)) $tablePKey = array($tablePKey);
|
||||
if (!is_array($tablePKey)) {
|
||||
$tablePKey = array($tablePKey);
|
||||
}
|
||||
$ar = new ADODB_Active_Record($table,$tablePKey);
|
||||
$ar->hasMany($foreignRef, $foreignKey, $foreignClass);
|
||||
}
|
||||
@@ -260,7 +284,9 @@ class ADODB_Active_Record {
|
||||
|
||||
static function TableKeyBelongsTo($table, $tablePKey, $foreignRef, $foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record')
|
||||
{
|
||||
if (!is_array($tablePKey)) $tablePKey = array($tablePKey);
|
||||
if (!is_array($tablePKey)) {
|
||||
$tablePKey = array($tablePKey);
|
||||
}
|
||||
$ar = new ADOdb_Active_Record($table, $tablePKey);
|
||||
$ar->belongsTo($foreignRef, $foreignKey, $parentKey, $parentClass);
|
||||
}
|
||||
@@ -289,24 +315,34 @@ class ADODB_Active_Record {
|
||||
{
|
||||
$extras = array();
|
||||
$table = $this->TableInfo();
|
||||
if ($limit >= 0) $extras['limit'] = $limit;
|
||||
if ($offset >= 0) $extras['offset'] = $offset;
|
||||
if ($limit >= 0) {
|
||||
$extras['limit'] = $limit;
|
||||
}
|
||||
if ($offset >= 0) {
|
||||
$extras['offset'] = $offset;
|
||||
}
|
||||
|
||||
if (strlen($whereOrderBy))
|
||||
if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy))
|
||||
if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i',$whereOrderBy))
|
||||
$whereOrderBy = 'AND '.$whereOrderBy;
|
||||
if (strlen($whereOrderBy)) {
|
||||
if (!preg_match('/^[ \n\r]*AND/i', $whereOrderBy)) {
|
||||
if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i', $whereOrderBy)) {
|
||||
$whereOrderBy = 'AND ' . $whereOrderBy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($table->_belongsTo[$name]))
|
||||
{
|
||||
if(!empty($table->_belongsTo[$name])) {
|
||||
$obj = $table->_belongsTo[$name];
|
||||
$columnName = $obj->foreignKey;
|
||||
if(empty($this->$columnName))
|
||||
if(empty($this->$columnName)) {
|
||||
$this->$name = null;
|
||||
else
|
||||
{
|
||||
if ($obj->parentKey) $key = $obj->parentKey;
|
||||
else $key = reset($table->keys);
|
||||
}
|
||||
else {
|
||||
if ($obj->parentKey) {
|
||||
$key = $obj->parentKey;
|
||||
}
|
||||
else {
|
||||
$key = reset($table->keys);
|
||||
}
|
||||
|
||||
$arrayOfOne = $obj->Find($key.'='.$this->$columnName.' '.$whereOrderBy,false,false,$extras);
|
||||
if ($arrayOfOne) {
|
||||
@@ -315,8 +351,7 @@ class ADODB_Active_Record {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($table->_hasMany[$name]))
|
||||
{
|
||||
if(!empty($table->_hasMany[$name])) {
|
||||
$obj = $table->_hasMany[$name];
|
||||
$key = reset($table->keys);
|
||||
$id = @$this->$key;
|
||||
@@ -325,7 +360,9 @@ class ADODB_Active_Record {
|
||||
$id = $db->qstr($id);
|
||||
}
|
||||
$objs = $obj->Find($obj->foreignKey.'='.$id. ' '.$whereOrderBy,false,false,$extras);
|
||||
if (!$objs) $objs = array();
|
||||
if (!$objs) {
|
||||
$objs = array();
|
||||
}
|
||||
$this->$name = $objs;
|
||||
return $objs;
|
||||
}
|
||||
@@ -349,10 +386,12 @@ class ADODB_Active_Record {
|
||||
|
||||
$acttab = $tables[$tableat];
|
||||
foreach($acttab->flds as $name => $fld) {
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value))
|
||||
$this->$name = $fld->default_value;
|
||||
else
|
||||
$this->$name = null;
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) {
|
||||
$this->$name = $fld->default_value;
|
||||
}
|
||||
else {
|
||||
$this->$name = null;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -368,10 +407,12 @@ class ADODB_Active_Record {
|
||||
// ideally, you should cache at least 32 secs
|
||||
|
||||
foreach($acttab->flds as $name => $fld) {
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value))
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fld->default_value)) {
|
||||
$this->$name = $fld->default_value;
|
||||
else
|
||||
}
|
||||
else {
|
||||
$this->$name = null;
|
||||
}
|
||||
}
|
||||
|
||||
$activedb->tables[$table] = $acttab;
|
||||
@@ -387,11 +428,15 @@ class ADODB_Active_Record {
|
||||
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||
if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false);
|
||||
if ($db->fetchMode !== false) {
|
||||
$savem = $db->SetFetchMode(false);
|
||||
}
|
||||
|
||||
$cols = $db->MetaColumns($table);
|
||||
|
||||
if (isset($savem)) $db->SetFetchMode($savem);
|
||||
if (isset($savem)) {
|
||||
$db->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
if (!$cols) {
|
||||
@@ -403,7 +448,9 @@ class ADODB_Active_Record {
|
||||
if (isset($fld->primary_key)) {
|
||||
$pkeys = array();
|
||||
foreach($cols as $name => $fld) {
|
||||
if (!empty($fld->primary_key)) $pkeys[] = $name;
|
||||
if (!empty($fld->primary_key)) {
|
||||
$pkeys[] = $name;
|
||||
}
|
||||
}
|
||||
} else
|
||||
$pkeys = $this->GetPrimaryKeys($db, $table);
|
||||
@@ -420,10 +467,12 @@ class ADODB_Active_Record {
|
||||
case 0:
|
||||
foreach($cols as $name => $fldobj) {
|
||||
$name = strtolower($name);
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
|
||||
$this->$name = $fldobj->default_value;
|
||||
else
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
|
||||
$this->$name = $fldobj->default_value;
|
||||
}
|
||||
else {
|
||||
$this->$name = null;
|
||||
}
|
||||
$attr[$name] = $fldobj;
|
||||
}
|
||||
foreach($pkeys as $k => $name) {
|
||||
@@ -435,10 +484,12 @@ class ADODB_Active_Record {
|
||||
foreach($cols as $name => $fldobj) {
|
||||
$name = strtoupper($name);
|
||||
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
|
||||
$this->$name = $fldobj->default_value;
|
||||
else
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
|
||||
$this->$name = $fldobj->default_value;
|
||||
}
|
||||
else {
|
||||
$this->$name = null;
|
||||
}
|
||||
$attr[$name] = $fldobj;
|
||||
}
|
||||
|
||||
@@ -450,10 +501,12 @@ class ADODB_Active_Record {
|
||||
foreach($cols as $name => $fldobj) {
|
||||
$name = ($fldobj->name);
|
||||
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
|
||||
$this->$name = $fldobj->default_value;
|
||||
else
|
||||
if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value)) {
|
||||
$this->$name = $fldobj->default_value;
|
||||
}
|
||||
else {
|
||||
$this->$name = null;
|
||||
}
|
||||
$attr[$name] = $fldobj;
|
||||
}
|
||||
foreach($pkeys as $k => $name) {
|
||||
@@ -468,14 +521,18 @@ class ADODB_Active_Record {
|
||||
if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) {
|
||||
$activetab->_created = time();
|
||||
$s = serialize($activetab);
|
||||
if (!function_exists('adodb_write_file')) include(ADODB_DIR.'/adodb-csvlib.inc.php');
|
||||
if (!function_exists('adodb_write_file')) {
|
||||
include(ADODB_DIR.'/adodb-csvlib.inc.php');
|
||||
}
|
||||
adodb_write_file($fname,$s);
|
||||
}
|
||||
if (isset($activedb->tables[$table])) {
|
||||
$oldtab = $activedb->tables[$table];
|
||||
|
||||
if ($oldtab) $activetab->_belongsTo = $oldtab->_belongsTo;
|
||||
if ($oldtab) $activetab->_hasMany = $oldtab->_hasMany;
|
||||
if ($oldtab) {
|
||||
$activetab->_belongsTo = $oldtab->_belongsTo;
|
||||
$activetab->_hasMany = $oldtab->_hasMany;
|
||||
}
|
||||
}
|
||||
$activedb->tables[$table] = $activetab;
|
||||
}
|
||||
@@ -493,17 +550,26 @@ class ADODB_Active_Record {
|
||||
$fn = get_class($this).'::'.$fn;
|
||||
$this->_lasterr = $fn.': '.$err;
|
||||
|
||||
if ($this->_dbat < 0) $db = false;
|
||||
if ($this->_dbat < 0) {
|
||||
$db = false;
|
||||
}
|
||||
else {
|
||||
$activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
|
||||
$db = $activedb->db;
|
||||
}
|
||||
|
||||
if (function_exists('adodb_throw')) {
|
||||
if (!$db) adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false);
|
||||
else adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db);
|
||||
} else
|
||||
if (!$db || $db->debug) ADOConnection::outp($this->_lasterr);
|
||||
if (!$db) {
|
||||
adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false);
|
||||
}
|
||||
else {
|
||||
adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db);
|
||||
}
|
||||
} else {
|
||||
if (!$db || $db->debug) {
|
||||
ADOConnection::outp($this->_lasterr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -511,18 +577,26 @@ class ADODB_Active_Record {
|
||||
function ErrorMsg()
|
||||
{
|
||||
if (!function_exists('adodb_throw')) {
|
||||
if ($this->_dbat < 0) $db = false;
|
||||
else $db = $this->DB();
|
||||
if ($this->_dbat < 0) {
|
||||
$db = false;
|
||||
}
|
||||
else {
|
||||
$db = $this->DB();
|
||||
}
|
||||
|
||||
// last error could be database error too
|
||||
if ($db && $db->ErrorMsg()) return $db->ErrorMsg();
|
||||
if ($db && $db->ErrorMsg()) {
|
||||
return $db->ErrorMsg();
|
||||
}
|
||||
}
|
||||
return $this->_lasterr;
|
||||
}
|
||||
|
||||
function ErrorNo()
|
||||
{
|
||||
if ($this->_dbat < 0) return -9999; // no database connection...
|
||||
if ($this->_dbat < 0) {
|
||||
return -9999; // no database connection...
|
||||
}
|
||||
$db = $this->DB();
|
||||
|
||||
return (int) $db->ErrorNo();
|
||||
@@ -558,8 +632,11 @@ class ADODB_Active_Record {
|
||||
// So, I find that for myTable, I want to reload an active record after saving it. -- Malcolm Cook
|
||||
function Reload()
|
||||
{
|
||||
$db =& $this->DB(); if (!$db) return false;
|
||||
$table =& $this->TableInfo();
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
$table = $this->TableInfo();
|
||||
$where = $this->GenWhere($db, $table);
|
||||
return($this->Load($where));
|
||||
}
|
||||
@@ -581,44 +658,47 @@ class ADODB_Active_Record {
|
||||
|
||||
$table = $this->TableInfo();
|
||||
if ($ACTIVE_RECORD_SAFETY && sizeof($table->flds) != sizeof($row)) {
|
||||
# <AP>
|
||||
$bad_size = TRUE;
|
||||
if (sizeof($row) == 2 * sizeof($table->flds)) {
|
||||
// Only keep string keys
|
||||
$keys = array_filter(array_keys($row), 'is_string');
|
||||
if (sizeof($keys) == sizeof($table->flds))
|
||||
$bad_size = FALSE;
|
||||
}
|
||||
if ($bad_size) {
|
||||
# <AP>
|
||||
$bad_size = TRUE;
|
||||
if (sizeof($row) == 2 * sizeof($table->flds)) {
|
||||
// Only keep string keys
|
||||
$keys = array_filter(array_keys($row), 'is_string');
|
||||
if (sizeof($keys) == sizeof($table->flds)) {
|
||||
$bad_size = FALSE;
|
||||
}
|
||||
}
|
||||
if ($bad_size) {
|
||||
$this->Error("Table structure of $this->_table has changed","Load");
|
||||
return false;
|
||||
}
|
||||
# </AP>
|
||||
# </AP>
|
||||
}
|
||||
else
|
||||
else
|
||||
$keys = array_keys($row);
|
||||
|
||||
# <AP>
|
||||
reset($keys);
|
||||
$this->_original = array();
|
||||
# <AP>
|
||||
reset($keys);
|
||||
$this->_original = array();
|
||||
foreach($table->flds as $name=>$fld) {
|
||||
$value = $row[current($keys)];
|
||||
$value = $row[current($keys)];
|
||||
$this->$name = $value;
|
||||
$this->_original[] = $value;
|
||||
next($keys);
|
||||
$this->_original[] = $value;
|
||||
next($keys);
|
||||
}
|
||||
|
||||
# </AP>
|
||||
# </AP>
|
||||
return true;
|
||||
}
|
||||
|
||||
// get last inserted id for INSERT
|
||||
function LastInsertID(&$db,$fieldname)
|
||||
{
|
||||
if ($db->hasInsertID)
|
||||
if ($db->hasInsertID) {
|
||||
$val = $db->Insert_ID($this->_table,$fieldname);
|
||||
else
|
||||
}
|
||||
else {
|
||||
$val = false;
|
||||
}
|
||||
|
||||
if (is_null($val) || $val === false) {
|
||||
// this might not work reliably in multi-user environment
|
||||
@@ -632,19 +712,25 @@ class ADODB_Active_Record {
|
||||
{
|
||||
switch($t) {
|
||||
case 'L':
|
||||
if (strpos($db->databaseType,'postgres') !== false) return $db->qstr($val);
|
||||
if (strpos($db->databaseType,'postgres') !== false) {
|
||||
return $db->qstr($val);
|
||||
}
|
||||
case 'D':
|
||||
case 'T':
|
||||
if (empty($val)) return 'null';
|
||||
|
||||
if (empty($val)) {
|
||||
return 'null';
|
||||
}
|
||||
case 'B':
|
||||
case 'N':
|
||||
case 'C':
|
||||
case 'X':
|
||||
if (is_null($val)) return 'null';
|
||||
if (is_null($val)) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (strlen($val)>0 &&
|
||||
(strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")) {
|
||||
(strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")
|
||||
) {
|
||||
return $db->qstr($val);
|
||||
break;
|
||||
}
|
||||
@@ -672,8 +758,15 @@ class ADODB_Active_Record {
|
||||
|
||||
function _QName($n,$db=false)
|
||||
{
|
||||
if (!ADODB_Active_Record::$_quoteNames) return $n;
|
||||
if (!$db) $db = $this->DB(); if (!$db) return false;
|
||||
if (!ADODB_Active_Record::$_quoteNames) {
|
||||
return $n;
|
||||
}
|
||||
if (!$db) {
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $db->nameQuote.$n.$db->nameQuote;
|
||||
}
|
||||
|
||||
@@ -683,23 +776,32 @@ class ADODB_Active_Record {
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
$db = $this->DB(); if (!$db) return false;
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
$this->_where = $where;
|
||||
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false);
|
||||
if ($db->fetchMode !== false) {
|
||||
$savem = $db->SetFetchMode(false);
|
||||
}
|
||||
|
||||
$qry = "select * from ".$this->_table;
|
||||
|
||||
if($where) {
|
||||
$qry .= ' WHERE '.$where;
|
||||
}
|
||||
if ($lock) $qry .= $this->lockMode;
|
||||
if ($lock) {
|
||||
$qry .= $this->lockMode;
|
||||
}
|
||||
|
||||
$row = $db->GetRow($qry,$bindarr);
|
||||
|
||||
if (isset($savem)) $db->SetFetchMode($savem);
|
||||
if (isset($savem)) {
|
||||
$db->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
return $this->Set($row);
|
||||
@@ -714,25 +816,29 @@ class ADODB_Active_Record {
|
||||
# see http://phplens.com/lens/lensforum/msgs.php?id=17795
|
||||
function Reset()
|
||||
{
|
||||
$this->_where=null;
|
||||
$this->_saved = false;
|
||||
$this->_lasterr = false;
|
||||
$this->_original = false;
|
||||
$vars=get_object_vars($this);
|
||||
foreach($vars as $k=>$v){
|
||||
if(substr($k,0,1)!=='_'){
|
||||
$this->{$k}=null;
|
||||
}
|
||||
}
|
||||
$this->foreignName=strtolower(get_class($this));
|
||||
return true;
|
||||
}
|
||||
$this->_where=null;
|
||||
$this->_saved = false;
|
||||
$this->_lasterr = false;
|
||||
$this->_original = false;
|
||||
$vars=get_object_vars($this);
|
||||
foreach($vars as $k=>$v){
|
||||
if(substr($k,0,1)!=='_'){
|
||||
$this->{$k}=null;
|
||||
}
|
||||
}
|
||||
$this->foreignName=strtolower(get_class($this));
|
||||
return true;
|
||||
}
|
||||
|
||||
// false on error
|
||||
function Save()
|
||||
{
|
||||
if ($this->_saved) $ok = $this->Update();
|
||||
else $ok = $this->Insert();
|
||||
if ($this->_saved) {
|
||||
$ok = $this->Update();
|
||||
}
|
||||
else {
|
||||
$ok = $this->Insert();
|
||||
}
|
||||
|
||||
return $ok;
|
||||
}
|
||||
@@ -741,7 +847,10 @@ class ADODB_Active_Record {
|
||||
// false on error
|
||||
function Insert()
|
||||
{
|
||||
$db = $this->DB(); if (!$db) return false;
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
$cnt = 0;
|
||||
$table = $this->TableInfo();
|
||||
|
||||
@@ -791,7 +900,10 @@ class ADODB_Active_Record {
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$db = $this->DB(); if (!$db) return false;
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
$table = $this->TableInfo();
|
||||
|
||||
$where = $this->GenWhere($db,$table);
|
||||
@@ -804,7 +916,10 @@ class ADODB_Active_Record {
|
||||
// returns an array of active record objects
|
||||
function Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array())
|
||||
{
|
||||
$db = $this->DB(); if (!$db || empty($this->_table)) return false;
|
||||
$db = $this->DB();
|
||||
if (!$db || empty($this->_table)) {
|
||||
return false;
|
||||
}
|
||||
$arr = $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr,$extra);
|
||||
return $arr;
|
||||
}
|
||||
@@ -814,7 +929,10 @@ class ADODB_Active_Record {
|
||||
{
|
||||
global $ADODB_ASSOC_CASE;
|
||||
|
||||
$db = $this->DB(); if (!$db) return false;
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
$table = $this->TableInfo();
|
||||
|
||||
$pkey = $table->keys;
|
||||
@@ -824,7 +942,9 @@ class ADODB_Active_Record {
|
||||
/*
|
||||
if (is_null($val)) {
|
||||
if (isset($fld->not_null) && $fld->not_null) {
|
||||
if (isset($fld->default_value) && strlen($fld->default_value)) continue;
|
||||
if (isset($fld->default_value) && strlen($fld->default_value)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$this->Error("Cannot update null into $name","Replace");
|
||||
return false;
|
||||
@@ -832,25 +952,31 @@ class ADODB_Active_Record {
|
||||
}
|
||||
}*/
|
||||
if (is_null($val) && !empty($fld->auto_increment)) {
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($val)) continue;
|
||||
if (is_array($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$t = $db->MetaType($fld->type);
|
||||
$arr[$name] = $this->doquote($db,$val,$t);
|
||||
$valarr[] = $val;
|
||||
}
|
||||
|
||||
if (!is_array($pkey)) $pkey = array($pkey);
|
||||
if (!is_array($pkey)) {
|
||||
$pkey = array($pkey);
|
||||
}
|
||||
|
||||
|
||||
if ($ADODB_ASSOC_CASE == 0)
|
||||
if ($ADODB_ASSOC_CASE == 0) {
|
||||
foreach($pkey as $k => $v)
|
||||
$pkey[$k] = strtolower($v);
|
||||
elseif ($ADODB_ASSOC_CASE == 1)
|
||||
foreach($pkey as $k => $v)
|
||||
}
|
||||
elseif ($ADODB_ASSOC_CASE == 1) {
|
||||
foreach($pkey as $k => $v) {
|
||||
$pkey[$k] = strtoupper($v);
|
||||
}
|
||||
}
|
||||
|
||||
$ok = $db->Replace($this->_table,$arr,$pkey);
|
||||
if ($ok) {
|
||||
@@ -877,7 +1003,10 @@ class ADODB_Active_Record {
|
||||
// returns 0 on error, 1 on update, -1 if no change in data (no update)
|
||||
function Update()
|
||||
{
|
||||
$db = $this->DB(); if (!$db) return false;
|
||||
$db = $this->DB();
|
||||
if (!$db) {
|
||||
return false;
|
||||
}
|
||||
$table = $this->TableInfo();
|
||||
|
||||
$where = $this->GenWhere($db, $table);
|
||||
@@ -896,12 +1025,15 @@ class ADODB_Active_Record {
|
||||
$val = $this->$name;
|
||||
$neworig[] = $val;
|
||||
|
||||
if (isset($table->keys[$name]) || is_array($val))
|
||||
if (isset($table->keys[$name]) || is_array($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($val)) {
|
||||
if (isset($fld->not_null) && $fld->not_null) {
|
||||
if (isset($fld->default_value) && strlen($fld->default_value)) continue;
|
||||
if (isset($fld->default_value) && strlen($fld->default_value)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$this->Error("Cannot set field $name to NULL","Update");
|
||||
return false;
|
||||
@@ -909,9 +1041,13 @@ class ADODB_Active_Record {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->_original[$i]) && strcmp($val,$this->_original[$i]) == 0) continue;
|
||||
if (isset($this->_original[$i]) && strcmp($val,$this->_original[$i]) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($this->_original[$i]) && is_null($val)) continue;
|
||||
if (is_null($this->_original[$i]) && is_null($val)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$valarr[] = $val;
|
||||
$pairs[] = $this->_QName($name,$db).'='.$db->Param($cnt);
|
||||
@@ -919,7 +1055,10 @@ class ADODB_Active_Record {
|
||||
}
|
||||
|
||||
|
||||
if (!$cnt) return -1;
|
||||
if (!$cnt) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where;
|
||||
$ok = $db->Execute($sql,$valarr);
|
||||
if ($ok) {
|
||||
@@ -932,7 +1071,9 @@ class ADODB_Active_Record {
|
||||
function GetAttributeNames()
|
||||
{
|
||||
$table = $this->TableInfo();
|
||||
if (!$table) return false;
|
||||
if (!$table) {
|
||||
return false;
|
||||
}
|
||||
return array_keys($table->flds);
|
||||
}
|
||||
|
||||
@@ -947,10 +1088,10 @@ global $_ADODB_ACTIVE_DBS;
|
||||
$save = $db->SetFetchMode(ADODB_FETCH_NUM);
|
||||
$qry = "select * from ".$table;
|
||||
|
||||
if (!empty($whereOrderBy))
|
||||
if (!empty($whereOrderBy)) {
|
||||
$qry .= ' WHERE '.$whereOrderBy;
|
||||
if(isset($extra['limit']))
|
||||
{
|
||||
}
|
||||
if(isset($extra['limit'])) {
|
||||
$rows = false;
|
||||
if(isset($extra['offset'])) {
|
||||
$rs = $db->SelectLimit($qry, $extra['limit'], $extra['offset'],$bindarr);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,9 @@ $ADODB_INCLUDED_CSV = 1;
|
||||
|
||||
/*
|
||||
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -292,7 +294,7 @@ $ADODB_INCLUDED_CSV = 1;
|
||||
// the tricky moment
|
||||
@unlink($filename);
|
||||
if (!@rename($tmpname,$filename)) {
|
||||
unlink($tmpname);
|
||||
@unlink($tmpname);
|
||||
$ok = 0;
|
||||
}
|
||||
if (!$ok) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
@@ -29,9 +31,9 @@ var $database = '';
|
||||
{
|
||||
switch($fn) {
|
||||
case 'EXECUTE':
|
||||
$this->sql = $p1;
|
||||
$this->sql = is_array($p1) ? $p1[0] : $p1;
|
||||
$this->params = $p2;
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
|
||||
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$this->sql\")\n";
|
||||
break;
|
||||
|
||||
case 'PCONNECT':
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
+78
-33
@@ -6,7 +6,9 @@ global $ADODB_INCLUDED_LIB;
|
||||
$ADODB_INCLUDED_LIB = 1;
|
||||
|
||||
/*
|
||||
@version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -17,7 +19,7 @@ $ADODB_INCLUDED_LIB = 1;
|
||||
|
||||
function adodb_strip_order_by($sql)
|
||||
{
|
||||
$rez = preg_match('/(\sORDER\s+BY\s(?:[^)](?!limit))*)(?:\sLIMIT\s+[0-9]+)?/is', $sql, $arr);
|
||||
$rez = preg_match('/(\sORDER\s+BY\s(?:[^)](?!LIMIT))*)/is', $sql, $arr);
|
||||
if ($arr)
|
||||
if (strpos($arr[1], '(') !== false) {
|
||||
$at = strpos($sql, $arr[1]);
|
||||
@@ -38,7 +40,7 @@ function adodb_strip_order_by($sql)
|
||||
$sql = str_replace($arr[1], '', $sql);
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
||||
if (false) {
|
||||
$sql = 'select * from (select a from b order by a(b),b(c) desc)';
|
||||
@@ -421,8 +423,11 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
|
||||
}
|
||||
} else {
|
||||
// now replace SELECT ... FROM with SELECT COUNT(*) FROM
|
||||
$rewritesql = preg_replace(
|
||||
'/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql);
|
||||
if ( strpos($sql, '_ADODB_COUNT') !== FALSE ) {
|
||||
$rewritesql = preg_replace('/^\s*?SELECT\s+_ADODB_COUNT(.*)_ADODB_COUNT\s/is','SELECT COUNT(*) ',$sql);
|
||||
} else {
|
||||
$rewritesql = preg_replace('/^\s*?SELECT\s.*?\s+(.*?)\s+FROM\s/is','SELECT COUNT(*) FROM ',$sql);
|
||||
}
|
||||
// fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails
|
||||
// with mssql, access and postgresql. Also a good speedup optimization - skips sorting!
|
||||
// also see http://phplens.com/lens/lensforum/msgs.php?id=12752
|
||||
@@ -543,46 +548,86 @@ function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
|
||||
return $rsreturn;
|
||||
}
|
||||
|
||||
// Iván Oliva version
|
||||
// Iván Oliva version
|
||||
function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
|
||||
{
|
||||
|
||||
$atfirstpage = false;
|
||||
$atlastpage = false;
|
||||
|
||||
if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page
|
||||
if (!isset($page) || $page <= 1) {
|
||||
// If page number <= 1, then we are at the first page
|
||||
$page = 1;
|
||||
$atfirstpage = true;
|
||||
}
|
||||
if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page
|
||||
if ($nrows <= 0) {
|
||||
// If an invalid nrows is supplied, we assume a default value of 10 rows per page
|
||||
$nrows = 10;
|
||||
}
|
||||
|
||||
// ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than
|
||||
// the last page number.
|
||||
$pagecounter = $page + 1;
|
||||
$pagecounteroffset = ($pagecounter * $nrows) - $nrows;
|
||||
if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
|
||||
else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache);
|
||||
if ($rstest) {
|
||||
while ($rstest && $rstest->EOF && $pagecounter>0) {
|
||||
$atlastpage = true;
|
||||
$pagecounter--;
|
||||
$pagecounteroffset = $nrows * ($pagecounter - 1);
|
||||
$rstest->Close();
|
||||
if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
|
||||
else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache);
|
||||
$pagecounteroffset = ($page * $nrows) - $nrows;
|
||||
|
||||
// To find out if there are more pages of rows, simply increase the limit or
|
||||
// nrows by 1 and see if that number of records was returned. If it was,
|
||||
// then we know there is at least one more page left, otherwise we are on
|
||||
// the last page. Therefore allow non-Count() paging with single queries
|
||||
// rather than three queries as was done before.
|
||||
$test_nrows = $nrows + 1;
|
||||
if ($secs2cache > 0) {
|
||||
$rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
|
||||
} else {
|
||||
$rsreturn = $zthis->SelectLimit($sql, $test_nrows, $pagecounteroffset, $inputarr, $secs2cache);
|
||||
}
|
||||
|
||||
// Now check to see if the number of rows returned was the higher value we asked for or not.
|
||||
if ( $rsreturn->_numOfRows == $test_nrows ) {
|
||||
// Still at least 1 more row, so we are not on last page yet...
|
||||
// Remove the last row from the RS.
|
||||
$rsreturn->_numOfRows = ( $rsreturn->_numOfRows - 1 );
|
||||
} elseif ( $rsreturn->_numOfRows == 0 && $page > 1 ) {
|
||||
// Likely requested a page that doesn't exist, so need to find the last
|
||||
// page and return it. Revert to original method and loop through pages
|
||||
// until we find some data...
|
||||
$pagecounter = $page + 1;
|
||||
$pagecounteroffset = ($pagecounter * $nrows) - $nrows;
|
||||
|
||||
$rstest = $rsreturn;
|
||||
if ($rstest) {
|
||||
while ($rstest && $rstest->EOF && $pagecounter > 0) {
|
||||
$atlastpage = true;
|
||||
$pagecounter--;
|
||||
$pagecounteroffset = $nrows * ($pagecounter - 1);
|
||||
$rstest->Close();
|
||||
if ($secs2cache>0) {
|
||||
$rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
|
||||
}
|
||||
else {
|
||||
$rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache);
|
||||
}
|
||||
}
|
||||
if ($rstest) $rstest->Close();
|
||||
}
|
||||
if ($rstest) $rstest->Close();
|
||||
if ($atlastpage) {
|
||||
// If we are at the last page or beyond it, we are going to retrieve it
|
||||
$page = $pagecounter;
|
||||
if ($page == 1) {
|
||||
// We have to do this again in case the last page is the same as
|
||||
// the first page, that is, the recordset has only 1 page.
|
||||
$atfirstpage = true;
|
||||
}
|
||||
}
|
||||
// We get the data we want
|
||||
$offset = $nrows * ($page-1);
|
||||
if ($secs2cache > 0) {
|
||||
$rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr);
|
||||
}
|
||||
else {
|
||||
$rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
|
||||
}
|
||||
} elseif ( $rsreturn->_numOfRows < $test_nrows ) {
|
||||
// Rows is less than what we asked for, so must be at the last page.
|
||||
$atlastpage = true;
|
||||
}
|
||||
if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it
|
||||
$page = $pagecounter;
|
||||
if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first
|
||||
//... page, that is, the recordset has only 1 page.
|
||||
}
|
||||
|
||||
// We get the data we want
|
||||
$offset = $nrows * ($page-1);
|
||||
if ($secs2cache > 0) $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr);
|
||||
else $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
|
||||
|
||||
// Before returning the RecordSet, we set the pagination properties we need
|
||||
if ($rsreturn) {
|
||||
|
||||
@@ -7,11 +7,13 @@ global $ADODB_INCLUDED_MEMCACHE;
|
||||
$ADODB_INCLUDED_MEMCACHE = 1;
|
||||
|
||||
global $ADODB_INCLUDED_CSV;
|
||||
if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php');
|
||||
if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
|
||||
|
||||
/*
|
||||
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -48,7 +50,7 @@ $db->CacheExecute($sql);
|
||||
var $_connected = false;
|
||||
var $_memcache = false;
|
||||
|
||||
function ADODB_Cache_MemCache(&$obj)
|
||||
function __construct(&$obj)
|
||||
{
|
||||
$this->hosts = $obj->memCacheHost;
|
||||
$this->port = $obj->memCachePort;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -55,7 +57,7 @@ class ADODB_Pager {
|
||||
// if you have multiple on 1 page.
|
||||
// $id should be only be [a-z0-9]*
|
||||
//
|
||||
function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
|
||||
function __construct(&$db,$sql,$id = 'adodb', $showPageLinks = false)
|
||||
{
|
||||
global $PHP_SELF;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
@@ -52,10 +54,6 @@ if (!defined('DB_OK')) {
|
||||
define("DB_OK", 1);
|
||||
define("DB_ERROR",-1);
|
||||
|
||||
// autoExecute constants
|
||||
define('DB_AUTOQUERY_INSERT', 1);
|
||||
define('DB_AUTOQUERY_UPDATE', 2);
|
||||
|
||||
/**
|
||||
* This is a special constant that tells DB the user hasn't specified
|
||||
* any particular get mode, so the default should be used.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -224,7 +226,7 @@ class adodb_perf {
|
||||
var $cliFormat = "%32s => %s \r\n";
|
||||
var $sql1 = 'sql1'; // used for casting sql1 to text for mssql
|
||||
var $explain = true;
|
||||
var $helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>";
|
||||
var $helpurl = '<a href="http://adodb.sourceforge.net/docs-adodb.htm#logsql">LogSQL help</a>';
|
||||
var $createTableSQL = false;
|
||||
var $maxLength = 2000;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
/*
|
||||
ADOdb Date Library, part of the ADOdb abstraction library
|
||||
Download: http://phplens.com/phpeverywhere/
|
||||
Download: http://adodb.sourceforge.net/#download
|
||||
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
|
||||
PHP native date functions use integer timestamps for computations.
|
||||
Because of this, dates are restricted to the years 1901-2038 on Unix
|
||||
|
||||
@@ -118,7 +118,7 @@ class dbObject {
|
||||
/**
|
||||
* NOP
|
||||
*/
|
||||
function dbObject( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ class dbTable extends dbObject {
|
||||
* @param string $prefix DB Object prefix
|
||||
* @param array $attributes Array of table attributes.
|
||||
*/
|
||||
function dbTable( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
$this->name = $this->prefix($attributes['NAME']);
|
||||
}
|
||||
@@ -642,7 +642,7 @@ class dbIndex extends dbObject {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function dbIndex( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
|
||||
$this->name = $this->prefix ($attributes['NAME']);
|
||||
@@ -786,7 +786,7 @@ class dbData extends dbObject {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function dbData( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
@@ -985,7 +985,7 @@ class dbQuerySet extends dbObject {
|
||||
* @param object $parent Parent object
|
||||
* @param array $attributes Attributes
|
||||
*/
|
||||
function dbQuerySet( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
|
||||
// Overrides the manual prefix key
|
||||
@@ -1301,7 +1301,7 @@ class adoSchema {
|
||||
*
|
||||
* @param object $db ADOdb database connection object.
|
||||
*/
|
||||
function adoSchema( $db ) {
|
||||
function __construct( $db ) {
|
||||
// Initialize the environment
|
||||
$this->mgq = get_magic_quotes_runtime();
|
||||
ini_set("magic_quotes_runtime", 0);
|
||||
|
||||
@@ -136,7 +136,7 @@ class dbObject {
|
||||
/**
|
||||
* NOP
|
||||
*/
|
||||
function dbObject( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ class dbTable extends dbObject {
|
||||
* @param string $prefix DB Object prefix
|
||||
* @param array $attributes Array of table attributes.
|
||||
*/
|
||||
function dbTable( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
$this->name = $this->prefix($attributes['NAME']);
|
||||
}
|
||||
@@ -683,7 +683,7 @@ class dbIndex extends dbObject {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function dbIndex( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
|
||||
$this->name = $this->prefix ($attributes['NAME']);
|
||||
@@ -828,7 +828,7 @@ class dbData extends dbObject {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function dbData( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,7 @@ class dbQuerySet extends dbObject {
|
||||
* @param object $parent Parent object
|
||||
* @param array $attributes Attributes
|
||||
*/
|
||||
function dbQuerySet( &$parent, $attributes = NULL ) {
|
||||
function __construct( &$parent, $attributes = NULL ) {
|
||||
$this->parent = $parent;
|
||||
|
||||
// Overrides the manual prefix key
|
||||
@@ -1405,7 +1405,7 @@ class adoSchema {
|
||||
*
|
||||
* @param object $db ADOdb database connection object.
|
||||
*/
|
||||
function adoSchema( $db ) {
|
||||
function __construct( $db ) {
|
||||
// Initialize the environment
|
||||
$this->mgq = get_magic_quotes_runtime();
|
||||
#set_magic_quotes_runtime(0);
|
||||
@@ -2104,11 +2104,12 @@ class adoSchema {
|
||||
|
||||
$schema = '<?xml version="1.0"?>' . "\n"
|
||||
. '<schema version="' . $this->schemaVersion . '">' . "\n";
|
||||
|
||||
if( is_array( $tables = $this->db->MetaTables( 'TABLES' , ($prefix) ? $prefix.'%' : '') ) ) {
|
||||
if( is_array( $tables = $this->db->MetaTables( 'TABLES' ,false ,($prefix) ? str_replace('_','\_',$prefix).'%' : '') ) ) {
|
||||
foreach( $tables as $table ) {
|
||||
if ($stripprefix) $table = str_replace(str_replace('\\_', '_', $pfx ), '', $table);
|
||||
$schema .= $indent . '<table name="' . htmlentities( $table ) . '">' . "\n";
|
||||
$schema .= $indent
|
||||
. '<table name="'
|
||||
. htmlentities( $stripprefix ? str_replace($prefix, '', $table) : $table )
|
||||
. '">' . "\n";
|
||||
|
||||
// grab details from database
|
||||
$rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE -1' );
|
||||
|
||||
+1618
-1172
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -77,14 +79,14 @@ class ADODB2_access extends ADODB_DataDict {
|
||||
{
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -58,14 +60,14 @@ class ADODB2_db2 extends ADODB_DataDict {
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -49,14 +51,14 @@ class ADODB2_generic extends ADODB_DataDict {
|
||||
}
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -49,14 +51,14 @@ class ADODB2_ibase extends ADODB_DataDict {
|
||||
}
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -49,14 +51,14 @@ class ADODB2_informix extends ADODB_DataDict {
|
||||
}
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
|
||||
return array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -124,7 +126,7 @@ class ADODB2_mssql extends ADODB_DataDict {
|
||||
}
|
||||
|
||||
/*
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
@@ -137,7 +139,7 @@ class ADODB2_mssql extends ADODB_DataDict {
|
||||
}
|
||||
*/
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds))
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -145,7 +147,7 @@ class ADODB2_mssqlnative extends ADODB_DataDict {
|
||||
}
|
||||
|
||||
/*
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -24,7 +26,7 @@ class ADODB2_oci8 extends ADODB_DataDict {
|
||||
var $typeX = 'VARCHAR(4000)';
|
||||
var $typeXL = 'CLOB';
|
||||
|
||||
function MetaType($t,$len=-1)
|
||||
function MetaType($t, $len=-1, $fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
@@ -116,6 +118,7 @@ class ADODB2_oci8 extends ADODB_DataDict {
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName($tabname);
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname ADD (";
|
||||
@@ -128,8 +131,9 @@ class ADODB2_oci8 extends ADODB_DataDict {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName($tabname);
|
||||
$f = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$s = "ALTER TABLE $tabname MODIFY(";
|
||||
@@ -141,7 +145,7 @@ class ADODB2_oci8 extends ADODB_DataDict {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -190,8 +192,8 @@ class ADODB2_postgres extends ADODB_DataDict {
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
$set_null = false;
|
||||
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
|
||||
foreach($lines as $v) {
|
||||
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
|
||||
if ($not_null = preg_match('/NOT NULL/i',$v)) {
|
||||
$v = preg_replace('/NOT NULL/i','',$v);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -100,7 +102,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
|
||||
return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
@@ -108,7 +110,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
|
||||
return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -67,13 +69,13 @@ class ADODB2_sqlite extends ADODB_DataDict {
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
|
||||
return array();
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
|
||||
return array();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -87,7 +89,7 @@ class ADODB2_sybase extends ADODB_DataDict {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
@@ -99,7 +101,7 @@ class ADODB2_sybase extends ADODB_DataDict {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
|
||||
{
|
||||
$tabname = $this->TableName($tabname);
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -29,12 +31,12 @@ class ADODB_access extends ADODB_odbc {
|
||||
var $hasTransactions = false;
|
||||
var $upperCase = 'ucase';
|
||||
|
||||
function ADODB_access()
|
||||
function __construct()
|
||||
{
|
||||
global $ADODB_EXTENSION;
|
||||
|
||||
$ADODB_EXTENSION = false;
|
||||
$this->ADODB_odbc();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function Time()
|
||||
@@ -78,9 +80,9 @@ class ADORecordSet_access extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = "access";
|
||||
|
||||
function ADORecordSet_access($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbc($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}// class
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -37,7 +39,7 @@ class ADODB_ado extends ADOConnection {
|
||||
var $poorAffectedRows = true;
|
||||
var $charPage;
|
||||
|
||||
function ADODB_ado()
|
||||
function __construct()
|
||||
{
|
||||
$this->_affectedRows = new VARIANT;
|
||||
}
|
||||
@@ -147,7 +149,7 @@ class ADODB_ado extends ADOConnection {
|
||||
|
||||
*/
|
||||
|
||||
function MetaTables()
|
||||
function MetaTables($ttype = false, $showSchema = false, $mask = false)
|
||||
{
|
||||
$arr= array();
|
||||
$dbc = $this->_connectionID;
|
||||
@@ -341,14 +343,14 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
var $canSeek = true;
|
||||
var $hideErrors = true;
|
||||
|
||||
function ADORecordSet_ado($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
$this->fetchMode = $mode;
|
||||
return $this->ADORecordSet($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -625,7 +627,7 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
@$rs->MoveNext(); // @ needed for some versions of PHP!
|
||||
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -37,7 +39,7 @@ class ADODB_ado extends ADOConnection {
|
||||
var $poorAffectedRows = true;
|
||||
var $charPage;
|
||||
|
||||
function ADODB_ado()
|
||||
function __construct()
|
||||
{
|
||||
$this->_affectedRows = new VARIANT;
|
||||
}
|
||||
@@ -172,7 +174,7 @@ class ADODB_ado extends ADOConnection {
|
||||
|
||||
*/
|
||||
|
||||
function MetaTables()
|
||||
function MetaTables($ttype = false, $showSchema = false, $mask = false)
|
||||
{
|
||||
$arr= array();
|
||||
$dbc = $this->_connectionID;
|
||||
@@ -375,14 +377,14 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
var $canSeek = true;
|
||||
var $hideErrors = true;
|
||||
|
||||
function ADORecordSet_ado($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
$this->fetchMode = $mode;
|
||||
return $this->ADORecordSet($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -670,7 +672,7 @@ class ADORecordSet_ado extends ADORecordSet {
|
||||
@$rs->MoveNext(); // @ needed for some versions of PHP!
|
||||
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -28,11 +30,6 @@ class ADODB_ado_access extends ADODB_ado {
|
||||
var $sysTimeStamp = 'NOW';
|
||||
var $upperCase = 'ucase';
|
||||
|
||||
function ADODB_ado_access()
|
||||
{
|
||||
$this->ADODB_ado();
|
||||
}
|
||||
|
||||
/*function BeginTrans() { return false;}
|
||||
|
||||
function CommitTrans() { return false;}
|
||||
@@ -46,8 +43,8 @@ class ADORecordSet_ado_access extends ADORecordSet_ado {
|
||||
|
||||
var $databaseType = "ado_access";
|
||||
|
||||
function ADORecordSet_ado_access($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_ado($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -39,11 +41,6 @@ class ADODB_ado_mssql extends ADODB_ado {
|
||||
|
||||
//var $_inTransaction = 1; // always open recordsets, so no transaction problems.
|
||||
|
||||
function ADODB_ado_mssql()
|
||||
{
|
||||
$this->ADODB_ado();
|
||||
}
|
||||
|
||||
function _insertid()
|
||||
{
|
||||
return $this->GetOne('select SCOPE_IDENTITY()');
|
||||
@@ -146,8 +143,8 @@ class ADODB_ado_mssql extends ADODB_ado {
|
||||
|
||||
var $databaseType = 'ado_mssql';
|
||||
|
||||
function ADORecordSet_ado_mssql($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_ado($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class ADODB_ads extends ADOConnection {
|
||||
var $uCaseTables = true; // for meta* functions, uppercase table names
|
||||
|
||||
|
||||
function ADODB_ads()
|
||||
function __construct()
|
||||
{
|
||||
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
|
||||
$this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
|
||||
@@ -136,7 +136,7 @@ class ADODB_ads extends ADOConnection {
|
||||
|
||||
|
||||
// returns true or false
|
||||
function CreateSequence( $seqname,$start=1)
|
||||
function CreateSequence($seqname = 'adodbseq', $start = 1)
|
||||
{
|
||||
$res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE");
|
||||
if(!$res){
|
||||
@@ -149,7 +149,7 @@ class ADODB_ads extends ADOConnection {
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
$res = $this->Execute("DROP TABLE $seqname");
|
||||
if(!$res){
|
||||
@@ -164,7 +164,7 @@ class ADODB_ads extends ADOConnection {
|
||||
// returns the generated ID or false
|
||||
// checks if the table already exists, else creates the table and inserts a record into the table
|
||||
// and gets the ID number of the last inserted record.
|
||||
function GenID($seqname,$start=1)
|
||||
function GenID($seqname = 'adodbseq', $start = 1)
|
||||
{
|
||||
$go = $this->Execute("select * from $seqname");
|
||||
if (!$go){
|
||||
@@ -254,7 +254,7 @@ class ADODB_ads extends ADOConnection {
|
||||
|
||||
// Returns tables,Views or both on succesfull execution. Returns
|
||||
// tables by default on succesfull execustion.
|
||||
function &MetaTables($ttype)
|
||||
function &MetaTables($ttype = false, $showSchema = false, $mask = false)
|
||||
{
|
||||
$recordSet1 = $this->Execute("select * from system.tables");
|
||||
if(!$recordSet1){
|
||||
@@ -294,7 +294,7 @@ class ADODB_ads extends ADOConnection {
|
||||
|
||||
}
|
||||
|
||||
function &MetaPrimaryKeys($table)
|
||||
function &MetaPrimaryKeys($table, $owner = false)
|
||||
{
|
||||
$recordSet = $this->Execute("select table_primary_key from system.tables where name='$table'");
|
||||
if(!$recordSet){
|
||||
@@ -378,7 +378,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
|
||||
}
|
||||
}
|
||||
|
||||
function &MetaColumns($table)
|
||||
function &MetaColumns($table, $normalize = true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
@@ -486,7 +486,7 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
|
||||
}
|
||||
|
||||
// Returns an array of columns names for a given table
|
||||
function &MetaColumnNames($table)
|
||||
function &MetaColumnNames($table, $numIndexes = false, $useattnum = false)
|
||||
{
|
||||
$recordSet = $this->Execute("select name from system.columns where parent='$table'");
|
||||
if(!$recordSet){
|
||||
@@ -654,7 +654,7 @@ class ADORecordSet_ads extends ADORecordSet {
|
||||
var $useFetchArray;
|
||||
var $_has_stupid_odbc_fetch_api_change;
|
||||
|
||||
function ADORecordSet_ads($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -667,7 +667,7 @@ class ADORecordSet_ads extends ADORecordSet {
|
||||
// the following is required for mysql odbc driver in 4.3.1 -- why?
|
||||
$this->EOF = false;
|
||||
$this->_currentRow = -1;
|
||||
//$this->ADORecordSet($id);
|
||||
//parent::__construct($id);
|
||||
}
|
||||
|
||||
|
||||
@@ -731,7 +731,7 @@ class ADORecordSet_ads extends ADORecordSet {
|
||||
$this->fetchMode = $savem;
|
||||
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields =& $this->GetRowAssoc();
|
||||
}
|
||||
|
||||
$results = array();
|
||||
@@ -769,7 +769,7 @@ class ADORecordSet_ads extends ADORecordSet {
|
||||
}
|
||||
if ($rez) {
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields =& $this->GetRowAssoc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -20,12 +22,6 @@ include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
|
||||
class ADODB_borland_ibase extends ADODB_ibase {
|
||||
var $databaseType = "borland_ibase";
|
||||
|
||||
|
||||
function ADODB_borland_ibase()
|
||||
{
|
||||
$this->ADODB_ibase();
|
||||
}
|
||||
|
||||
function BeginTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
@@ -84,8 +80,8 @@ class ADORecordSet_borland_ibase extends ADORecordSet_ibase {
|
||||
|
||||
var $databaseType = "borland_ibase";
|
||||
|
||||
function ADORecordSet_borland_ibase($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_ibase($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -36,7 +38,7 @@ class ADODB_csv extends ADOConnection {
|
||||
var $hasTransactions = false;
|
||||
var $_errorNo = false;
|
||||
|
||||
function ADODB_csv()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -79,7 +81,7 @@ class ADODB_csv extends ADOConnection {
|
||||
|
||||
|
||||
// parameters use PostgreSQL convention, not MySQL
|
||||
function SelectLimit($sql,$nrows=-1,$offset=-1)
|
||||
function SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
@@ -191,9 +193,9 @@ class ADODB_csv extends ADOConnection {
|
||||
} // class
|
||||
|
||||
class ADORecordset_csv extends ADORecordset {
|
||||
function ADORecordset_csv($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordset($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
function _close()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2012 (jlim#natsoft.com). All rights reserved.
|
||||
/**
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
|
||||
This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension
|
||||
for PHP (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2 or
|
||||
@@ -61,7 +63,7 @@ class ADODB_db2 extends ADOConnection {
|
||||
return ADOConnection::GetOne('VALUES IDENTITY_VAL_LOCAL()');
|
||||
}
|
||||
|
||||
function ADODB_db2()
|
||||
function __construct()
|
||||
{
|
||||
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
|
||||
}
|
||||
@@ -134,7 +136,7 @@ class ADODB_db2 extends ADOConnection {
|
||||
}
|
||||
|
||||
// format and return date string in database timestamp format
|
||||
function DBTimeStamp($ts)
|
||||
function DBTimeStamp($ts, $isfld = false)
|
||||
{
|
||||
if (empty($ts) && $ts !== 0) return 'null';
|
||||
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
|
||||
@@ -233,13 +235,13 @@ class ADODB_db2 extends ADOConnection {
|
||||
return true;
|
||||
}
|
||||
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
if (empty($this->_dropSeqSQL)) return false;
|
||||
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -333,7 +335,7 @@ class ADODB_db2 extends ADOConnection {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function MetaPrimaryKeys($table)
|
||||
function MetaPrimaryKeys($table, $owner = false)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
@@ -409,7 +411,7 @@ class ADODB_db2 extends ADOConnection {
|
||||
}
|
||||
|
||||
|
||||
function MetaTables($ttype=false,$schema=false)
|
||||
function MetaTables($ttype = false, $schema = false, $mask = false)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
@@ -726,7 +728,7 @@ class ADORecordSet_db2 extends ADORecordSet {
|
||||
var $dataProvider = "db2";
|
||||
var $useFetchArray;
|
||||
|
||||
function ADORecordSet_db2($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -793,7 +795,7 @@ class ADORecordSet_db2 extends ADORecordSet {
|
||||
$this->fetchMode = $savem;
|
||||
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
|
||||
$results = array();
|
||||
@@ -815,7 +817,7 @@ class ADORecordSet_db2 extends ADORecordSet {
|
||||
$this->fields = @db2_fetch_array($this->_queryID);
|
||||
if ($this->fields) {
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -831,7 +833,7 @@ class ADORecordSet_db2 extends ADORecordSet {
|
||||
$this->fields = db2_fetch_array($this->_queryID);
|
||||
if ($this->fields) {
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -158,18 +160,13 @@ class ADODB_db2oci extends ADODB_db2 {
|
||||
var $sysDate = 'trunc(sysdate)';
|
||||
var $_bindInputArray = true;
|
||||
|
||||
function ADODB_db2oci()
|
||||
{
|
||||
parent::ADODB_db2();
|
||||
}
|
||||
|
||||
function Param($name,$type='C')
|
||||
{
|
||||
return ':'.$name;
|
||||
}
|
||||
|
||||
|
||||
function MetaTables($ttype=false,$schema=false)
|
||||
function MetaTables($ttype = false, $schema = false, $mask = false)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
@@ -220,9 +217,9 @@ class ADORecordSet_db2oci extends ADORecordSet_db2 {
|
||||
|
||||
var $databaseType = "db2oci";
|
||||
|
||||
function ADORecordSet_db2oci($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_db2($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -52,13 +54,7 @@ class ADODB_db2oci extends ADODB_db2 {
|
||||
var $sysTimeStamp = 'sysdate';
|
||||
var $sysDate = 'trunc(sysdate)';
|
||||
|
||||
function ADODB_db2oci()
|
||||
{
|
||||
$this->ADODB_db2();
|
||||
}
|
||||
|
||||
|
||||
function _Execute($sql, $inputarr)
|
||||
function _Execute($sql, $inputarr = false)
|
||||
{
|
||||
if ($inputarr) list($sql,$inputarr) = _colonscope($sql, $inputarr);
|
||||
return parent::_Execute($sql, $inputarr);
|
||||
@@ -70,9 +66,9 @@ class ADORecordSet_db2oci extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = "db2oci";
|
||||
|
||||
function ADORecordSet_db2oci($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_db2($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
@version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -23,7 +25,7 @@ class ADODB_fbsql extends ADOConnection {
|
||||
var $fmtTimeStamp = "'Y-m-d H:i:s'";
|
||||
var $hasLimit = false;
|
||||
|
||||
function ADODB_fbsql()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -162,7 +164,7 @@ class ADORecordSet_fbsql extends ADORecordSet{
|
||||
var $databaseType = "fbsql";
|
||||
var $canSeek = true;
|
||||
|
||||
function ADORecordSet_fbsql($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if (!$mode) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -175,7 +177,7 @@ class ADORecordSet_fbsql extends ADORecordSet{
|
||||
default:
|
||||
$this->fetchMode = FBSQL_BOTH; break;
|
||||
}
|
||||
return $this->ADORecordSet($queryID);
|
||||
return parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -21,11 +23,6 @@ class ADODB_firebird extends ADODB_ibase {
|
||||
|
||||
var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)";
|
||||
|
||||
function ADODB_firebird()
|
||||
{
|
||||
$this->ADODB_ibase();
|
||||
}
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
$arr['dialect'] = $this->dialect;
|
||||
@@ -69,8 +66,8 @@ class ADORecordSet_firebird extends ADORecordSet_ibase {
|
||||
|
||||
var $databaseType = "firebird";
|
||||
|
||||
function ADORecordSet_firebird($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_ibase($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -54,13 +56,13 @@ class ADODB_ibase extends ADOConnection {
|
||||
var $blobEncodeType = 'C';
|
||||
var $role = false;
|
||||
|
||||
function ADODB_ibase()
|
||||
function __construct()
|
||||
{
|
||||
if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
|
||||
}
|
||||
if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
// returns true or false
|
||||
// returns true or false
|
||||
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
|
||||
{
|
||||
if (!function_exists('ibase_pconnect')) return null;
|
||||
@@ -84,8 +86,12 @@ class ADODB_ibase extends ADOConnection {
|
||||
// PHP5 change.
|
||||
if (function_exists('ibase_timefmt')) {
|
||||
ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
|
||||
if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
|
||||
else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
|
||||
if ($this->dialect == 1) {
|
||||
ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
|
||||
}
|
||||
else {
|
||||
ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
|
||||
}
|
||||
ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
|
||||
|
||||
} else {
|
||||
@@ -95,7 +101,8 @@ class ADODB_ibase extends ADOConnection {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// returns true or false
|
||||
|
||||
// returns true or false
|
||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
|
||||
@@ -104,7 +111,9 @@ class ADODB_ibase extends ADOConnection {
|
||||
|
||||
function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
|
||||
{
|
||||
if ($internalKey) return array('RDB$DB_KEY');
|
||||
if ($internalKey) {
|
||||
return array('RDB$DB_KEY');
|
||||
}
|
||||
|
||||
$table = strtoupper($table);
|
||||
|
||||
@@ -138,19 +147,25 @@ class ADODB_ibase extends ADOConnection {
|
||||
if ($this->transOff) return true;
|
||||
$this->transCnt += 1;
|
||||
$this->autoCommit = false;
|
||||
$this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID);
|
||||
$this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID);
|
||||
return $this->_transactionID;
|
||||
}
|
||||
|
||||
function CommitTrans($ok=true)
|
||||
{
|
||||
if (!$ok) return $this->RollbackTrans();
|
||||
if ($this->transOff) return true;
|
||||
if ($this->transCnt) $this->transCnt -= 1;
|
||||
if (!$ok) {
|
||||
return $this->RollbackTrans();
|
||||
}
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
if ($this->transCnt) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
$ret = false;
|
||||
$this->autoCommit = true;
|
||||
if ($this->_transactionID) {
|
||||
//print ' commit ';
|
||||
//print ' commit ';
|
||||
$ret = ibase_commit($this->_transactionID);
|
||||
}
|
||||
$this->_transactionID = false;
|
||||
@@ -180,8 +195,9 @@ class ADODB_ibase extends ADOConnection {
|
||||
if ($this->transCnt) $this->transCnt -= 1;
|
||||
$ret = false;
|
||||
$this->autoCommit = true;
|
||||
if ($this->_transactionID)
|
||||
$ret = ibase_rollback($this->_transactionID);
|
||||
if ($this->_transactionID) {
|
||||
$ret = ibase_rollback($this->_transactionID);
|
||||
}
|
||||
$this->_transactionID = false;
|
||||
|
||||
return $ret;
|
||||
@@ -189,75 +205,79 @@ class ADODB_ibase extends ADOConnection {
|
||||
|
||||
function MetaIndexes ($table, $primary = FALSE, $owner=false)
|
||||
{
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
$table = strtoupper($table);
|
||||
$sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'";
|
||||
if (!$primary) {
|
||||
$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'";
|
||||
} else {
|
||||
$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'";
|
||||
}
|
||||
// get index details
|
||||
$rs = $this->Execute($sql);
|
||||
if (!is_object($rs)) {
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
$table = strtoupper($table);
|
||||
$sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'";
|
||||
if (!$primary) {
|
||||
$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'";
|
||||
} else {
|
||||
$sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'";
|
||||
}
|
||||
// get index details
|
||||
$rs = $this->Execute($sql);
|
||||
if (!is_object($rs)) {
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
|
||||
$indexes = array();
|
||||
$indexes = array();
|
||||
while ($row = $rs->FetchRow()) {
|
||||
$index = $row[0];
|
||||
if (!isset($indexes[$index])) {
|
||||
if (is_null($row[3])) {$row[3] = 0;}
|
||||
$indexes[$index] = array(
|
||||
'unique' => ($row[3] == 1),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
if (!isset($indexes[$index])) {
|
||||
if (is_null($row[3])) {
|
||||
$row[3] = 0;
|
||||
}
|
||||
$indexes[$index] = array(
|
||||
'unique' => ($row[3] == 1),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
$sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$index."' ORDER BY RDB\$FIELD_POSITION ASC";
|
||||
$rs1 = $this->Execute($sql);
|
||||
while ($row1 = $rs1->FetchRow()) {
|
||||
$indexes[$index]['columns'][$row1[2]] = $row1[1];
|
||||
}
|
||||
while ($row1 = $rs1->FetchRow()) {
|
||||
$indexes[$index]['columns'][$row1[2]] = $row1[1];
|
||||
}
|
||||
}
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
return $indexes;
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
|
||||
// See http://community.borland.com/article/0,1410,25844,00.html
|
||||
function RowLock($tables,$where,$col=false)
|
||||
{
|
||||
if ($this->autoCommit) $this->BeginTrans();
|
||||
if ($this->autoCommit) {
|
||||
$this->BeginTrans();
|
||||
}
|
||||
$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function CreateSequence($seqname,$startID=1)
|
||||
function CreateSequence($seqname = 'adodbseq', $startID = 1)
|
||||
{
|
||||
$ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
|
||||
if (!$ok) return false;
|
||||
return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
|
||||
}
|
||||
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
$seqname = strtoupper($seqname);
|
||||
$this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'");
|
||||
@@ -272,17 +292,23 @@ class ADODB_ibase extends ADOConnection {
|
||||
$this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
|
||||
$rs = $this->Execute($getnext);
|
||||
}
|
||||
if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
|
||||
else $this->genID = 0; // false
|
||||
if ($rs && !$rs->EOF) {
|
||||
$this->genID = (integer) reset($rs->fields);
|
||||
}
|
||||
else {
|
||||
$this->genID = 0; // false
|
||||
}
|
||||
|
||||
if ($rs) $rs->Close();
|
||||
if ($rs) {
|
||||
$rs->Close();
|
||||
}
|
||||
|
||||
return $this->genID;
|
||||
}
|
||||
|
||||
function SelectDB($dbName)
|
||||
{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function _handleerror()
|
||||
@@ -308,8 +334,8 @@ class ADODB_ibase extends ADOConnection {
|
||||
return array($sql,$stmt);
|
||||
}
|
||||
|
||||
// returns query ID if successful, otherwise false
|
||||
// there have been reports of problems with nested queries - the code is probably not re-entrant?
|
||||
// returns query ID if successful, otherwise false
|
||||
// there have been reports of problems with nested queries - the code is probably not re-entrant?
|
||||
function _query($sql,$iarr=false)
|
||||
{
|
||||
|
||||
@@ -365,18 +391,22 @@ class ADODB_ibase extends ADOConnection {
|
||||
}
|
||||
} else $ret = $fn($conn,$sql);
|
||||
}
|
||||
if ($docommit && $ret === true) ibase_commit($this->_connectionID);
|
||||
if ($docommit && $ret === true) {
|
||||
ibase_commit($this->_connectionID);
|
||||
}
|
||||
|
||||
$this->_handleerror();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function _close()
|
||||
{
|
||||
if (!$this->autoCommit) @ibase_rollback($this->_connectionID);
|
||||
// returns true or false
|
||||
function _close()
|
||||
{
|
||||
if (!$this->autoCommit) {
|
||||
@ibase_rollback($this->_connectionID);
|
||||
}
|
||||
return @ibase_close($this->_connectionID);
|
||||
}
|
||||
}
|
||||
|
||||
//OPN STUFF start
|
||||
function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3)
|
||||
@@ -388,24 +418,24 @@ class ADODB_ibase extends ADOConnection {
|
||||
case 7:
|
||||
case 8:
|
||||
if ($dialect3) {
|
||||
switch($fsubtype){
|
||||
case 0:
|
||||
$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
|
||||
break;
|
||||
case 1:
|
||||
$fld->type = 'numeric';
|
||||
switch($fsubtype){
|
||||
case 0:
|
||||
$fld->type = ($ftype == 7 ? 'smallint' : 'integer');
|
||||
break;
|
||||
case 1:
|
||||
$fld->type = 'numeric';
|
||||
$fld->max_length = $fprecision;
|
||||
$fld->scale = $fscale;
|
||||
break;
|
||||
case 2:
|
||||
$fld->type = 'decimal';
|
||||
break;
|
||||
case 2:
|
||||
$fld->type = 'decimal';
|
||||
$fld->max_length = $fprecision;
|
||||
$fld->scale = $fscale;
|
||||
break;
|
||||
} // switch
|
||||
break;
|
||||
} // switch
|
||||
} else {
|
||||
if ($fscale !=0) {
|
||||
$fld->type = 'decimal';
|
||||
$fld->type = 'decimal';
|
||||
$fld->scale = $fscale;
|
||||
$fld->max_length = ($ftype == 7 ? 4 : 9);
|
||||
} else {
|
||||
@@ -415,23 +445,23 @@ class ADODB_ibase extends ADOConnection {
|
||||
break;
|
||||
case 16:
|
||||
if ($dialect3) {
|
||||
switch($fsubtype){
|
||||
case 0:
|
||||
$fld->type = 'decimal';
|
||||
switch($fsubtype){
|
||||
case 0:
|
||||
$fld->type = 'decimal';
|
||||
$fld->max_length = 18;
|
||||
$fld->scale = 0;
|
||||
break;
|
||||
case 1:
|
||||
$fld->type = 'numeric';
|
||||
break;
|
||||
case 1:
|
||||
$fld->type = 'numeric';
|
||||
$fld->max_length = $fprecision;
|
||||
$fld->scale = $fscale;
|
||||
break;
|
||||
case 2:
|
||||
$fld->type = 'decimal';
|
||||
break;
|
||||
case 2:
|
||||
$fld->type = 'decimal';
|
||||
$fld->max_length = $fprecision;
|
||||
$fld->scale = $fscale;
|
||||
break;
|
||||
} // switch
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
@@ -442,7 +472,7 @@ class ADODB_ibase extends ADOConnection {
|
||||
break;
|
||||
case 27:
|
||||
if ($fscale !=0) {
|
||||
$fld->type = 'decimal';
|
||||
$fld->type = 'decimal';
|
||||
$fld->max_length = 15;
|
||||
$fld->scale = 5;
|
||||
} else {
|
||||
@@ -451,7 +481,7 @@ class ADODB_ibase extends ADOConnection {
|
||||
break;
|
||||
case 35:
|
||||
if ($dialect3) {
|
||||
$fld->type = 'timestamp';
|
||||
$fld->type = 'timestamp';
|
||||
} else {
|
||||
$fld->type = 'date';
|
||||
}
|
||||
@@ -475,7 +505,8 @@ class ADODB_ibase extends ADOConnection {
|
||||
} // switch
|
||||
}
|
||||
//OPN STUFF end
|
||||
// returns array of ADOFieldObjects for current table
|
||||
|
||||
// returns array of ADOFieldObjects for current table
|
||||
function MetaColumns($table, $normalize=true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -569,29 +600,29 @@ class ADODB_ibase extends ADOConnection {
|
||||
}
|
||||
|
||||
function _BlobDecode( $blob )
|
||||
{
|
||||
if (ADODB_PHPVER >= 0x5000) {
|
||||
$blob_data = ibase_blob_info($this->_connectionID, $blob );
|
||||
$blobid = ibase_blob_open($this->_connectionID, $blob );
|
||||
} else {
|
||||
{
|
||||
if (ADODB_PHPVER >= 0x5000) {
|
||||
$blob_data = ibase_blob_info($this->_connectionID, $blob );
|
||||
$blobid = ibase_blob_open($this->_connectionID, $blob );
|
||||
} else {
|
||||
|
||||
$blob_data = ibase_blob_info( $blob );
|
||||
$blobid = ibase_blob_open( $blob );
|
||||
}
|
||||
$blob_data = ibase_blob_info( $blob );
|
||||
$blobid = ibase_blob_open( $blob );
|
||||
}
|
||||
|
||||
if( $blob_data[0] > $this->maxblobsize ) {
|
||||
if( $blob_data[0] > $this->maxblobsize ) {
|
||||
|
||||
$realblob = ibase_blob_get($blobid, $this->maxblobsize);
|
||||
$realblob = ibase_blob_get($blobid, $this->maxblobsize);
|
||||
|
||||
while($string = ibase_blob_get($blobid, 8192)){
|
||||
$realblob .= $string;
|
||||
}
|
||||
} else {
|
||||
$realblob = ibase_blob_get($blobid, $blob_data[0]);
|
||||
}
|
||||
while($string = ibase_blob_get($blobid, 8192)){
|
||||
$realblob .= $string;
|
||||
}
|
||||
} else {
|
||||
$realblob = ibase_blob_get($blobid, $blob_data[0]);
|
||||
}
|
||||
|
||||
ibase_blob_close( $blobid );
|
||||
return( $realblob );
|
||||
ibase_blob_close( $blobid );
|
||||
return( $realblob );
|
||||
}
|
||||
|
||||
function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
|
||||
@@ -695,16 +726,16 @@ class ADODB_ibase extends ADOConnection {
|
||||
break;
|
||||
case 'H':
|
||||
case 'h':
|
||||
$s .= "(extract(hour from $col))";
|
||||
break;
|
||||
$s .= "(extract(hour from $col))";
|
||||
break;
|
||||
case 'I':
|
||||
case 'i':
|
||||
$s .= "(extract(minute from $col))";
|
||||
break;
|
||||
$s .= "(extract(minute from $col))";
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
$s .= "CAST((extract(second from $col)) AS INTEGER)";
|
||||
break;
|
||||
$s .= "CAST((extract(second from $col)) AS INTEGER)";
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($ch == '\\') {
|
||||
@@ -720,7 +751,7 @@ class ADODB_ibase extends ADOConnection {
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
class ADORecordset_ibase extends ADORecordSet
|
||||
@@ -730,12 +761,12 @@ class ADORecordset_ibase extends ADORecordSet
|
||||
var $bind=false;
|
||||
var $_cacheType;
|
||||
|
||||
function ADORecordset_ibase($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
$this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode;
|
||||
$this->ADORecordSet($id);
|
||||
parent::__construct($id);
|
||||
}
|
||||
|
||||
/* Returns: an object containing field information.
|
||||
@@ -745,31 +776,32 @@ class ADORecordset_ibase extends ADORecordSet
|
||||
|
||||
function FetchField($fieldOffset = -1)
|
||||
{
|
||||
$fld = new ADOFieldObject;
|
||||
$ibf = ibase_field_info($this->_queryID,$fieldOffset);
|
||||
switch (ADODB_ASSOC_CASE) {
|
||||
case 2: // the default
|
||||
$fld->name = ($ibf['alias']);
|
||||
if (empty($fld->name)) $fld->name = ($ibf['name']);
|
||||
break;
|
||||
case 0:
|
||||
$fld->name = strtoupper($ibf['alias']);
|
||||
if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
|
||||
break;
|
||||
case 1:
|
||||
$fld->name = strtolower($ibf['alias']);
|
||||
if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
|
||||
break;
|
||||
}
|
||||
$fld = new ADOFieldObject;
|
||||
$ibf = ibase_field_info($this->_queryID,$fieldOffset);
|
||||
|
||||
$fld->type = $ibf['type'];
|
||||
$fld->max_length = $ibf['length'];
|
||||
$name = empty($ibf['alias']) ? $ibf['name'] : $ibf['alias'];
|
||||
|
||||
/* This needs to be populated from the metadata */
|
||||
$fld->not_null = false;
|
||||
$fld->has_default = false;
|
||||
$fld->default_value = 'null';
|
||||
return $fld;
|
||||
switch (ADODB_ASSOC_CASE) {
|
||||
case ADODB_ASSOC_CASE_UPPER:
|
||||
$fld->name = strtoupper($name);
|
||||
break;
|
||||
case ADODB_ASSOC_CASE_LOWER:
|
||||
$fld->name = strtolower($name);
|
||||
break;
|
||||
case ADODB_ASSOC_CASE_NATIVE:
|
||||
default:
|
||||
$fld->name = $name;
|
||||
break;
|
||||
}
|
||||
|
||||
$fld->type = $ibf['type'];
|
||||
$fld->max_length = $ibf['length'];
|
||||
|
||||
/* This needs to be populated from the metadata */
|
||||
$fld->not_null = false;
|
||||
$fld->has_default = false;
|
||||
$fld->default_value = 'null';
|
||||
return $fld;
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
@@ -822,9 +854,9 @@ class ADORecordset_ibase extends ADORecordSet
|
||||
|
||||
$this->fields = $f;
|
||||
if ($this->fetchMode == ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
} else if ($this->fetchMode == ADODB_FETCH_BOTH) {
|
||||
$this->fields = array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE));
|
||||
$this->fields = array_merge($this->fields,$this->GetRowAssoc());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
@@ -32,8 +34,8 @@ class ADODB_informix extends ADODB_informix72 {
|
||||
class ADORecordset_informix extends ADORecordset_informix72 {
|
||||
var $databaseType = "informix";
|
||||
|
||||
function ADORecordset_informix($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordset_informix72($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim. All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -54,7 +56,7 @@ class ADODB_informix72 extends ADOConnection {
|
||||
var $sysTimeStamp = 'CURRENT';
|
||||
var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0
|
||||
|
||||
function ADODB_informix72()
|
||||
function __construct()
|
||||
{
|
||||
// alternatively, use older method:
|
||||
//putenv("DBDATE=Y4MD-");
|
||||
@@ -391,14 +393,14 @@ class ADORecordset_informix72 extends ADORecordSet {
|
||||
var $canSeek = true;
|
||||
var $_fieldprops = false;
|
||||
|
||||
function ADORecordset_informix72($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
$this->fetchMode = $mode;
|
||||
return $this->ADORecordSet($id);
|
||||
return parent::__construct($id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -18,22 +20,22 @@
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
if (!defined('LDAP_ASSOC')) {
|
||||
define('LDAP_ASSOC',ADODB_FETCH_ASSOC);
|
||||
define('LDAP_NUM',ADODB_FETCH_NUM);
|
||||
define('LDAP_BOTH',ADODB_FETCH_BOTH);
|
||||
define('LDAP_ASSOC',ADODB_FETCH_ASSOC);
|
||||
define('LDAP_NUM',ADODB_FETCH_NUM);
|
||||
define('LDAP_BOTH',ADODB_FETCH_BOTH);
|
||||
}
|
||||
|
||||
class ADODB_ldap extends ADOConnection {
|
||||
var $databaseType = 'ldap';
|
||||
var $databaseType = 'ldap';
|
||||
var $dataProvider = 'ldap';
|
||||
|
||||
# Connection information
|
||||
var $username = false;
|
||||
var $password = false;
|
||||
var $username = false;
|
||||
var $password = false;
|
||||
|
||||
# Used during searches
|
||||
var $filter;
|
||||
var $dn;
|
||||
# Used during searches
|
||||
var $filter;
|
||||
var $dn;
|
||||
var $version;
|
||||
var $port = 389;
|
||||
|
||||
@@ -43,7 +45,7 @@ class ADODB_ldap extends ADOConnection {
|
||||
# error on binding, eg. "Binding: invalid credentials"
|
||||
var $_bind_errmsg = "Binding: %s";
|
||||
|
||||
function ADODB_ldap()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -51,7 +53,7 @@ class ADODB_ldap extends ADOConnection {
|
||||
|
||||
function _connect( $host, $username, $password, $ldapbase)
|
||||
{
|
||||
global $LDAP_CONNECT_OPTIONS;
|
||||
global $LDAP_CONNECT_OPTIONS;
|
||||
|
||||
if ( !function_exists( 'ldap_connect' ) ) return null;
|
||||
|
||||
@@ -61,7 +63,7 @@ class ADODB_ldap extends ADOConnection {
|
||||
$conn_info = array( $host,$this->port);
|
||||
|
||||
if ( strstr( $host, ':' ) ) {
|
||||
$conn_info = explode( ':', $host );
|
||||
$conn_info = explode( ':', $host );
|
||||
}
|
||||
|
||||
$this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] );
|
||||
@@ -77,10 +79,10 @@ class ADODB_ldap extends ADOConnection {
|
||||
}
|
||||
|
||||
if ($username) {
|
||||
$bind = @ldap_bind( $this->_connectionID, $username, $password );
|
||||
$bind = @ldap_bind( $this->_connectionID, $username, $password );
|
||||
} else {
|
||||
$username = 'anonymous';
|
||||
$bind = @ldap_bind( $this->_connectionID );
|
||||
$bind = @ldap_bind( $this->_connectionID );
|
||||
}
|
||||
|
||||
if (!$bind) {
|
||||
@@ -171,7 +173,7 @@ class ADODB_ldap extends ADOConnection {
|
||||
return @ldap_errno($this->_connectionID);
|
||||
}
|
||||
|
||||
/* closes the LDAP connection */
|
||||
/* closes the LDAP connection */
|
||||
function _close()
|
||||
{
|
||||
@ldap_close( $this->_connectionID );
|
||||
@@ -183,105 +185,107 @@ class ADODB_ldap extends ADOConnection {
|
||||
return true;
|
||||
} // SelectDB
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
if( !empty( $this->version ) ) return $this->version;
|
||||
$version = array();
|
||||
/*
|
||||
Determines how aliases are handled during search.
|
||||
LDAP_DEREF_NEVER (0x00)
|
||||
LDAP_DEREF_SEARCHING (0x01)
|
||||
LDAP_DEREF_FINDING (0x02)
|
||||
LDAP_DEREF_ALWAYS (0x03)
|
||||
The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but
|
||||
not when locating the base object of the search. The LDAP_DEREF_FINDING value means
|
||||
aliases are dereferenced when locating the base object but not during the search.
|
||||
Default: LDAP_DEREF_NEVER
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_DEREF, $version['LDAP_OPT_DEREF'] ) ;
|
||||
switch ( $version['LDAP_OPT_DEREF'] ) {
|
||||
case 0:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_NEVER';
|
||||
case 1:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_SEARCHING';
|
||||
case 2:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_FINDING';
|
||||
case 3:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_ALWAYS';
|
||||
}
|
||||
function ServerInfo()
|
||||
{
|
||||
if( !empty( $this->version ) ) {
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/*
|
||||
A limit on the number of entries to return from a search.
|
||||
LDAP_NO_LIMIT (0) means no limit.
|
||||
Default: LDAP_NO_LIMIT
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_SIZELIMIT, $version['LDAP_OPT_SIZELIMIT'] );
|
||||
if ( $version['LDAP_OPT_SIZELIMIT'] == 0 ) {
|
||||
$version['LDAP_OPT_SIZELIMIT'] = 'LDAP_NO_LIMIT';
|
||||
}
|
||||
$version = array();
|
||||
/*
|
||||
Determines how aliases are handled during search.
|
||||
LDAP_DEREF_NEVER (0x00)
|
||||
LDAP_DEREF_SEARCHING (0x01)
|
||||
LDAP_DEREF_FINDING (0x02)
|
||||
LDAP_DEREF_ALWAYS (0x03)
|
||||
The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but
|
||||
not when locating the base object of the search. The LDAP_DEREF_FINDING value means
|
||||
aliases are dereferenced when locating the base object but not during the search.
|
||||
Default: LDAP_DEREF_NEVER
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_DEREF, $version['LDAP_OPT_DEREF'] ) ;
|
||||
switch ( $version['LDAP_OPT_DEREF'] ) {
|
||||
case 0:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_NEVER';
|
||||
case 1:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_SEARCHING';
|
||||
case 2:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_FINDING';
|
||||
case 3:
|
||||
$version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_ALWAYS';
|
||||
}
|
||||
|
||||
/*
|
||||
A limit on the number of seconds to spend on a search.
|
||||
LDAP_NO_LIMIT (0) means no limit.
|
||||
Default: LDAP_NO_LIMIT
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_TIMELIMIT, $version['LDAP_OPT_TIMELIMIT'] );
|
||||
if ( $version['LDAP_OPT_TIMELIMIT'] == 0 ) {
|
||||
$version['LDAP_OPT_TIMELIMIT'] = 'LDAP_NO_LIMIT';
|
||||
}
|
||||
/*
|
||||
A limit on the number of entries to return from a search.
|
||||
LDAP_NO_LIMIT (0) means no limit.
|
||||
Default: LDAP_NO_LIMIT
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_SIZELIMIT, $version['LDAP_OPT_SIZELIMIT'] );
|
||||
if ( $version['LDAP_OPT_SIZELIMIT'] == 0 ) {
|
||||
$version['LDAP_OPT_SIZELIMIT'] = 'LDAP_NO_LIMIT';
|
||||
}
|
||||
|
||||
/*
|
||||
Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not.
|
||||
LDAP_OPT_ON
|
||||
LDAP_OPT_OFF
|
||||
Default: ON
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_REFERRALS, $version['LDAP_OPT_REFERRALS'] );
|
||||
if ( $version['LDAP_OPT_REFERRALS'] == 0 ) {
|
||||
$version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF';
|
||||
} else {
|
||||
$version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON';
|
||||
/*
|
||||
A limit on the number of seconds to spend on a search.
|
||||
LDAP_NO_LIMIT (0) means no limit.
|
||||
Default: LDAP_NO_LIMIT
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_TIMELIMIT, $version['LDAP_OPT_TIMELIMIT'] );
|
||||
if ( $version['LDAP_OPT_TIMELIMIT'] == 0 ) {
|
||||
$version['LDAP_OPT_TIMELIMIT'] = 'LDAP_NO_LIMIT';
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
Determines whether LDAP I/O operations are automatically restarted if they abort prematurely.
|
||||
LDAP_OPT_ON
|
||||
LDAP_OPT_OFF
|
||||
Default: OFF
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_RESTART, $version['LDAP_OPT_RESTART'] );
|
||||
if ( $version['LDAP_OPT_RESTART'] == 0 ) {
|
||||
$version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF';
|
||||
} else {
|
||||
$version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON';
|
||||
/*
|
||||
Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not.
|
||||
LDAP_OPT_ON
|
||||
LDAP_OPT_OFF
|
||||
Default: ON
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_REFERRALS, $version['LDAP_OPT_REFERRALS'] );
|
||||
if ( $version['LDAP_OPT_REFERRALS'] == 0 ) {
|
||||
$version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF';
|
||||
} else {
|
||||
$version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON';
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server.
|
||||
LDAP_VERSION2 (2)
|
||||
LDAP_VERSION3 (3)
|
||||
Default: LDAP_VERSION2 (2)
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_PROTOCOL_VERSION, $version['LDAP_OPT_PROTOCOL_VERSION'] );
|
||||
if ( $version['LDAP_OPT_PROTOCOL_VERSION'] == 2 ) {
|
||||
$version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2';
|
||||
} else {
|
||||
$version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3';
|
||||
/*
|
||||
Determines whether LDAP I/O operations are automatically restarted if they abort prematurely.
|
||||
LDAP_OPT_ON
|
||||
LDAP_OPT_OFF
|
||||
Default: OFF
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_RESTART, $version['LDAP_OPT_RESTART'] );
|
||||
if ( $version['LDAP_OPT_RESTART'] == 0 ) {
|
||||
$version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF';
|
||||
} else {
|
||||
$version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON';
|
||||
}
|
||||
|
||||
}
|
||||
/* The host name (or list of hosts) for the primary LDAP server. */
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] );
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] );
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_STRING, $version['LDAP_OPT_ERROR_STRING'] );
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] );
|
||||
/*
|
||||
This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server.
|
||||
LDAP_VERSION2 (2)
|
||||
LDAP_VERSION3 (3)
|
||||
Default: LDAP_VERSION2 (2)
|
||||
*/
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_PROTOCOL_VERSION, $version['LDAP_OPT_PROTOCOL_VERSION'] );
|
||||
if ( $version['LDAP_OPT_PROTOCOL_VERSION'] == 2 ) {
|
||||
$version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2';
|
||||
} else {
|
||||
$version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3';
|
||||
}
|
||||
|
||||
return $this->version = $version;
|
||||
/* The host name (or list of hosts) for the primary LDAP server. */
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] );
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] );
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_STRING, $version['LDAP_OPT_ERROR_STRING'] );
|
||||
ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] );
|
||||
|
||||
}
|
||||
return $this->version = $version;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
class ADORecordSet_ldap extends ADORecordSet{
|
||||
@@ -290,7 +294,7 @@ class ADORecordSet_ldap extends ADORecordSet{
|
||||
var $canSeek = false;
|
||||
var $_entryID; /* keeps track of the entry resource identifier */
|
||||
|
||||
function ADORecordSet_ldap($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -299,119 +303,121 @@ class ADORecordSet_ldap extends ADORecordSet{
|
||||
switch ($mode)
|
||||
{
|
||||
case ADODB_FETCH_NUM:
|
||||
$this->fetchMode = LDAP_NUM;
|
||||
break;
|
||||
$this->fetchMode = LDAP_NUM;
|
||||
break;
|
||||
case ADODB_FETCH_ASSOC:
|
||||
$this->fetchMode = LDAP_ASSOC;
|
||||
break;
|
||||
$this->fetchMode = LDAP_ASSOC;
|
||||
break;
|
||||
case ADODB_FETCH_DEFAULT:
|
||||
case ADODB_FETCH_BOTH:
|
||||
default:
|
||||
$this->fetchMode = LDAP_BOTH;
|
||||
break;
|
||||
$this->fetchMode = LDAP_BOTH;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
{
|
||||
/*
|
||||
This could be teaked to respect the $COUNTRECS directive from ADODB
|
||||
It's currently being used in the _fetch() function and the
|
||||
GetAssoc() function
|
||||
*/
|
||||
$this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID );
|
||||
|
||||
/*
|
||||
This could be teaked to respect the $COUNTRECS directive from ADODB
|
||||
It's currently being used in the _fetch() function and the
|
||||
GetAssoc() function
|
||||
*/
|
||||
$this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID );
|
||||
}
|
||||
|
||||
/*
|
||||
Return whole recordset as a multi-dimensional associative array
|
||||
/*
|
||||
Return whole recordset as a multi-dimensional associative array
|
||||
*/
|
||||
function GetAssoc($force_array = false, $first2cols = false)
|
||||
{
|
||||
$records = $this->_numOfRows;
|
||||
$results = array();
|
||||
for ( $i=0; $i < $records; $i++ ) {
|
||||
foreach ( $this->fields as $k=>$v ) {
|
||||
if ( is_array( $v ) ) {
|
||||
if ( $v['count'] == 1 ) {
|
||||
$results[$i][$k] = $v[0];
|
||||
} else {
|
||||
array_shift( $v );
|
||||
$results[$i][$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$results = array();
|
||||
for ( $i=0; $i < $records; $i++ ) {
|
||||
foreach ( $this->fields as $k=>$v ) {
|
||||
if ( is_array( $v ) ) {
|
||||
if ( $v['count'] == 1 ) {
|
||||
$results[$i][$k] = $v[0];
|
||||
} else {
|
||||
array_shift( $v );
|
||||
$results[$i][$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function GetRowAssoc()
|
||||
function GetRowAssoc($upper = ADODB_ASSOC_CASE)
|
||||
{
|
||||
$results = array();
|
||||
foreach ( $this->fields as $k=>$v ) {
|
||||
if ( is_array( $v ) ) {
|
||||
if ( $v['count'] == 1 ) {
|
||||
$results[$k] = $v[0];
|
||||
} else {
|
||||
array_shift( $v );
|
||||
$results[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
$results = array();
|
||||
foreach ( $this->fields as $k=>$v ) {
|
||||
if ( is_array( $v ) ) {
|
||||
if ( $v['count'] == 1 ) {
|
||||
$results[$k] = $v[0];
|
||||
} else {
|
||||
array_shift( $v );
|
||||
$results[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function GetRowNums()
|
||||
{
|
||||
$results = array();
|
||||
foreach ( $this->fields as $k=>$v ) {
|
||||
static $i = 0;
|
||||
if (is_array( $v )) {
|
||||
if ( $v['count'] == 1 ) {
|
||||
$results[$i] = $v[0];
|
||||
} else {
|
||||
array_shift( $v );
|
||||
$results[$i] = $v;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
function GetRowNums()
|
||||
{
|
||||
$results = array();
|
||||
foreach ( $this->fields as $k=>$v ) {
|
||||
static $i = 0;
|
||||
if (is_array( $v )) {
|
||||
if ( $v['count'] == 1 ) {
|
||||
$results[$i] = $v[0];
|
||||
} else {
|
||||
array_shift( $v );
|
||||
$results[$i] = $v;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
function _fetch()
|
||||
{
|
||||
if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 )
|
||||
return false;
|
||||
if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->_currentRow == 0 ) {
|
||||
$this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID );
|
||||
} else {
|
||||
$this->_entryID = ldap_next_entry( $this->connection->_connectionID, $this->_entryID );
|
||||
}
|
||||
if ( $this->_currentRow == 0 ) {
|
||||
$this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID );
|
||||
} else {
|
||||
$this->_entryID = ldap_next_entry( $this->connection->_connectionID, $this->_entryID );
|
||||
}
|
||||
|
||||
$this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID );
|
||||
$this->_numOfFields = $this->fields['count'];
|
||||
switch ( $this->fetchMode ) {
|
||||
$this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID );
|
||||
$this->_numOfFields = $this->fields['count'];
|
||||
|
||||
case LDAP_ASSOC:
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
break;
|
||||
switch ( $this->fetchMode ) {
|
||||
|
||||
case LDAP_NUM:
|
||||
$this->fields = array_merge($this->GetRowNums(),$this->GetRowAssoc());
|
||||
break;
|
||||
case LDAP_ASSOC:
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
break;
|
||||
|
||||
case LDAP_BOTH:
|
||||
default:
|
||||
$this->fields = $this->GetRowNums();
|
||||
break;
|
||||
}
|
||||
return ( is_array( $this->fields ) );
|
||||
case LDAP_NUM:
|
||||
$this->fields = array_merge($this->GetRowNums(),$this->GetRowAssoc());
|
||||
break;
|
||||
|
||||
case LDAP_BOTH:
|
||||
default:
|
||||
$this->fields = $this->GetRowNums();
|
||||
break;
|
||||
}
|
||||
|
||||
return is_array( $this->fields );
|
||||
}
|
||||
|
||||
function _close() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -105,7 +107,7 @@ class ADODB_mssql extends ADOConnection {
|
||||
var $_bindInputArray = true;
|
||||
var $forceNewConnect = false;
|
||||
|
||||
function ADODB_mssql()
|
||||
function __construct()
|
||||
{
|
||||
$this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
|
||||
}
|
||||
@@ -865,7 +867,7 @@ class ADORecordset_mssql extends ADORecordSet {
|
||||
var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083
|
||||
// _mths works only in non-localised system
|
||||
|
||||
function ADORecordset_mssql($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
// freedts check...
|
||||
$this->hasFetchAssoc = function_exists('mssql_fetch_assoc');
|
||||
@@ -876,7 +878,7 @@ class ADORecordset_mssql extends ADORecordSet {
|
||||
|
||||
}
|
||||
$this->fetchMode = $mode;
|
||||
return $this->ADORecordSet($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -1068,9 +1070,9 @@ class ADORecordset_mssql extends ADORecordSet {
|
||||
|
||||
|
||||
class ADORecordSet_array_mssql extends ADORecordSet_array {
|
||||
function ADORecordSet_array_mssql($id=-1,$mode=false)
|
||||
function __construct($id=-1,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_array($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
// mssql uses a default date like Dec 30 2000 12:00AM
|
||||
|
||||
@@ -64,107 +64,191 @@ class ADODB_mssql_n extends ADODB_mssql {
|
||||
return ADODB_mssql::_query($sql,$inputarr);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* This function will intercept all the literals used in the SQL, prepending the "N" char to them
|
||||
* in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS
|
||||
* and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add
|
||||
* the "N" notation when working against MSSQL.
|
||||
*
|
||||
* Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,
|
||||
* nvarchar and ntext
|
||||
* The orginal note indicated that this hack should only be used if ALL the char-based columns
|
||||
* in your DB are of type nchar, nvarchar and ntext, but testing seems to indicate that SQL server
|
||||
* doesn't seem to care if the statement is used against char etc fields.
|
||||
*
|
||||
* @todo This function should raise an ADOdb error if one of the transformations fail
|
||||
*
|
||||
* @param mixed $inboundData Either a string containing an SQL statement
|
||||
* or an array with resources from prepared statements
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function _appendN($sql) {
|
||||
function _appendN($inboundData) {
|
||||
|
||||
$result = $sql;
|
||||
$inboundIsArray = false;
|
||||
|
||||
if (is_array($inboundData))
|
||||
{
|
||||
$inboundIsArray = true;
|
||||
$inboundArray = $inboundData;
|
||||
} else
|
||||
$inboundArray = (array)$inboundData;
|
||||
|
||||
/*
|
||||
* All changes will be placed here
|
||||
*/
|
||||
$outboundArray = $inboundArray;
|
||||
|
||||
foreach($inboundArray as $inboundKey=>$inboundValue)
|
||||
{
|
||||
|
||||
if (is_resource($inboundValue))
|
||||
{
|
||||
/*
|
||||
* Prepared statement resource
|
||||
*/
|
||||
if ($this->debug)
|
||||
ADOConnection::outp("{$this->databaseType} index $inboundKey value is resource, continue");
|
||||
|
||||
/// Check we have some single quote in the query. Exit ok.
|
||||
if (strpos($sql, SINGLEQUOTE) === false) {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/// Check we haven't an odd number of single quotes (this can cause problems below
|
||||
/// and should be considered one wrong SQL). Exit with debug info.
|
||||
if ((substr_count($sql, SINGLEQUOTE) & 1)) {
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
|
||||
continue;
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/// Check we haven't any backslash + single quote combination. It should mean wrong
|
||||
/// backslashes use (bad magic_quotes_sybase?). Exit with debug info.
|
||||
$regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
|
||||
if (preg_match($regexp, $sql)) {
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
|
||||
|
||||
if (strpos($inboundValue, SINGLEQUOTE) === false)
|
||||
{
|
||||
/*
|
||||
* Check we have something to manipulate
|
||||
*/
|
||||
if ($this->debug)
|
||||
ADOConnection::outp("{$this->databaseType} index $inboundKey value $inboundValue has no single quotes, continue");
|
||||
continue;
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/// Remove pairs of single-quotes
|
||||
$pairs = array();
|
||||
$regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';
|
||||
preg_match_all($regexp, $result, $list_of_pairs);
|
||||
if ($list_of_pairs) {
|
||||
foreach (array_unique($list_of_pairs[0]) as $key=>$value) {
|
||||
$pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;
|
||||
/*
|
||||
* Check we haven't an odd number of single quotes (this can cause problems below
|
||||
* and should be considered one wrong SQL). Exit with debug info.
|
||||
*/
|
||||
if ((substr_count($inboundValue, SINGLEQUOTE) & 1))
|
||||
{
|
||||
if ($this->debug)
|
||||
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
|
||||
|
||||
break;
|
||||
}
|
||||
if (!empty($pairs)) {
|
||||
$result = str_replace($pairs, array_keys($pairs), $result);
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove the rest of literals present in the query
|
||||
$literals = array();
|
||||
$regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';
|
||||
preg_match_all($regexp, $result, $list_of_literals);
|
||||
if ($list_of_literals) {
|
||||
foreach (array_unique($list_of_literals[0]) as $key=>$value) {
|
||||
$literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;
|
||||
/*
|
||||
* Check we haven't any backslash + single quote combination. It should mean wrong
|
||||
* backslashes use (bad magic_quotes_sybase?). Exit with debug info.
|
||||
*/
|
||||
$regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
|
||||
if (preg_match($regexp, $inboundValue))
|
||||
{
|
||||
if ($this->debug)
|
||||
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
|
||||
|
||||
break;
|
||||
}
|
||||
if (!empty($literals)) {
|
||||
$result = str_replace($literals, array_keys($literals), $result);
|
||||
|
||||
/*
|
||||
* Remove pairs of single-quotes
|
||||
*/
|
||||
$pairs = array();
|
||||
$regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';
|
||||
preg_match_all($regexp, $inboundValue, $list_of_pairs);
|
||||
|
||||
if ($list_of_pairs)
|
||||
{
|
||||
foreach (array_unique($list_of_pairs[0]) as $key=>$value)
|
||||
$pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;
|
||||
|
||||
|
||||
if (!empty($pairs))
|
||||
$inboundValue = str_replace($pairs, array_keys($pairs), $inboundValue);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the rest of literals present in the query
|
||||
*/
|
||||
$literals = array();
|
||||
$regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';
|
||||
preg_match_all($regexp, $inboundValue, $list_of_literals);
|
||||
|
||||
if ($list_of_literals)
|
||||
{
|
||||
foreach (array_unique($list_of_literals[0]) as $key=>$value)
|
||||
$literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;
|
||||
|
||||
|
||||
if (!empty($literals))
|
||||
$inboundValue = str_replace($literals, array_keys($literals), $inboundValue);
|
||||
}
|
||||
|
||||
/// Analyse literals to prepend the N char to them if their contents aren't numeric
|
||||
if (!empty($literals)) {
|
||||
foreach ($literals as $key=>$value) {
|
||||
if (!is_numeric(trim($value, SINGLEQUOTE))) {
|
||||
/// Non numeric string, prepend our dear N
|
||||
$literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N"
|
||||
/*
|
||||
* Analyse literals to prepend the N char to them if their contents aren't numeric
|
||||
*/
|
||||
if (!empty($literals))
|
||||
{
|
||||
foreach ($literals as $key=>$value) {
|
||||
if (!is_numeric(trim($value, SINGLEQUOTE)))
|
||||
/*
|
||||
* Non numeric string, prepend our dear N, whilst
|
||||
* Trimming potentially existing previous "N"
|
||||
*/
|
||||
$literals[$key] = 'N' . trim($value, 'N');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-apply literals to the text
|
||||
*/
|
||||
if (!empty($literals))
|
||||
$inboundValue = str_replace(array_keys($literals), $literals, $inboundValue);
|
||||
|
||||
|
||||
/*
|
||||
* Any pairs followed by N' must be switched to N' followed by those pairs
|
||||
* (or strings beginning with single quotes will fail)
|
||||
*/
|
||||
$inboundValue = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $inboundValue);
|
||||
|
||||
/*
|
||||
* Re-apply pairs of single-quotes to the text
|
||||
*/
|
||||
if (!empty($pairs))
|
||||
$inboundValue = str_replace(array_keys($pairs), $pairs, $inboundValue);
|
||||
|
||||
|
||||
/*
|
||||
* Print transformation if debug = on
|
||||
*/
|
||||
if (strcmp($inboundValue,$inboundArray[$inboundKey]) <> 0 && $this->debug)
|
||||
ADOConnection::outp("{$this->databaseType} internal transformation: {$inboundArray[$inboundKey]} to {$inboundValue}");
|
||||
|
||||
if (strcmp($inboundValue,$inboundArray[$inboundKey]) <> 0)
|
||||
/*
|
||||
* Place the transformed value into the outbound array
|
||||
*/
|
||||
$outboundArray[$inboundKey] = $inboundValue;
|
||||
}
|
||||
|
||||
/// Re-apply literals to the text
|
||||
if (!empty($literals)) {
|
||||
$result = str_replace(array_keys($literals), $literals, $result);
|
||||
}
|
||||
|
||||
/// Any pairs followed by N' must be switched to N' followed by those pairs
|
||||
/// (or strings beginning with single quotes will fail)
|
||||
$result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result);
|
||||
|
||||
/// Re-apply pairs of single-quotes to the text
|
||||
if (!empty($pairs)) {
|
||||
$result = str_replace(array_keys($pairs), $pairs, $result);
|
||||
}
|
||||
|
||||
/// Print transformation if debug = on
|
||||
if ($result != $sql && $this->debug) {
|
||||
ADOConnection::outp("{$this->databaseType} internal transformation:<br>{$sql}<br>to<br>{$result}");
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
/*
|
||||
* Any transformations are in the $outboundArray
|
||||
*/
|
||||
if ($inboundIsArray)
|
||||
return $outboundArray;
|
||||
|
||||
/*
|
||||
* We passed a string in originally
|
||||
*/
|
||||
return $outboundArray[0];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ADORecordset_mssql_n extends ADORecordset_mssql {
|
||||
var $databaseType = "mssql_n";
|
||||
function ADORecordset_mssql_n($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordset_mssql($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -126,20 +128,20 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
var $sequences = false;
|
||||
var $mssql_version = '';
|
||||
|
||||
function ADODB_mssqlnative()
|
||||
function __construct()
|
||||
{
|
||||
if ($this->debug) {
|
||||
error_log("<pre>");
|
||||
sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
|
||||
sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL );
|
||||
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
|
||||
sqlsrv_configure('warnings_return_as_errors', 0);
|
||||
} else {
|
||||
sqlsrv_set_error_handling(0);
|
||||
sqlsrv_log_set_severity(0);
|
||||
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
|
||||
sqlsrv_configure('warnings_return_as_errors', 0);
|
||||
}
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp("<pre>");
|
||||
sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
|
||||
sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL );
|
||||
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
|
||||
sqlsrv_configure('WarningsReturnAsErrors', 0);
|
||||
} else {
|
||||
sqlsrv_set_error_handling(0);
|
||||
sqlsrv_log_set_severity(0);
|
||||
sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
|
||||
sqlsrv_configure('WarningsReturnAsErrors', 0);
|
||||
}
|
||||
}
|
||||
function ServerVersion() {
|
||||
$data = $this->ServerInfo();
|
||||
@@ -239,13 +241,13 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
*/
|
||||
function CreateSequence2008($seq='adodbseq',$start=1)
|
||||
{
|
||||
if($this->debug) error_log("<hr>CreateSequence($seq,$start)");
|
||||
if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
|
||||
sqlsrv_begin_transaction($this->_connectionID);
|
||||
$start -= 1;
|
||||
$this->Execute("create table $seq (id int)");//was float(53)
|
||||
$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
|
||||
if (!$ok) {
|
||||
if($this->debug) error_log("<hr>Error: ROLLBACK");
|
||||
if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
|
||||
sqlsrv_rollback($this->_connectionID);
|
||||
return false;
|
||||
}
|
||||
@@ -272,7 +274,7 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
*/
|
||||
function GenID2008($seq='adodbseq',$start=1)
|
||||
{
|
||||
if($this->debug) error_log("<hr>CreateSequence($seq,$start)");
|
||||
if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
|
||||
sqlsrv_begin_transaction($this->_connectionID);
|
||||
$ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
|
||||
if (!$ok) {
|
||||
@@ -280,7 +282,7 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
$this->Execute("create table $seq (id int)");//was float(53)
|
||||
$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
|
||||
if (!$ok) {
|
||||
if($this->debug) error_log("<hr>Error: ROLLBACK");
|
||||
if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
|
||||
sqlsrv_rollback($this->_connectionID);
|
||||
return false;
|
||||
}
|
||||
@@ -383,7 +385,7 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
$this->transCnt += 1;
|
||||
if ($this->debug) error_log('<hr>begin transaction');
|
||||
if ($this->debug) ADOConnection::outp('<hr>begin transaction');
|
||||
sqlsrv_begin_transaction($this->_connectionID);
|
||||
return true;
|
||||
}
|
||||
@@ -391,7 +393,7 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
function CommitTrans($ok=true)
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
if ($this->debug) error_log('<hr>commit transaction');
|
||||
if ($this->debug) ADOConnection::outp('<hr>commit transaction');
|
||||
if (!$ok) return $this->RollbackTrans();
|
||||
if ($this->transCnt) $this->transCnt -= 1;
|
||||
sqlsrv_commit($this->_connectionID);
|
||||
@@ -400,7 +402,7 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
function RollbackTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
if ($this->debug) error_log('<hr>rollback transaction');
|
||||
if ($this->debug) ADOConnection::outp('<hr>rollback transaction');
|
||||
if ($this->transCnt) $this->transCnt -= 1;
|
||||
sqlsrv_rollback($this->_connectionID);
|
||||
return true;
|
||||
@@ -480,14 +482,18 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
$connectionInfo["Database"]=$argDatabasename;
|
||||
$connectionInfo["UID"]=$argUsername;
|
||||
$connectionInfo["PWD"]=$argPassword;
|
||||
if ($this->debug) error_log("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
|
||||
//if ($this->debug) error_log("<hr>_connectionID before: ".serialize($this->_connectionID));
|
||||
|
||||
foreach ($this->connectionParameters as $parameter=>$value)
|
||||
$connectionInfo[$parameter] = $value;
|
||||
|
||||
if ($this->debug) ADOConnection::outp("<hr>connecting... hostname: $argHostname params: ".var_export($connectionInfo,true));
|
||||
//if ($this->debug) ADOConnection::outp("<hr>_connectionID before: ".serialize($this->_connectionID));
|
||||
if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) {
|
||||
if ($this->debug) error_log( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true));
|
||||
if ($this->debug) ADOConnection::outp( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true));
|
||||
return false;
|
||||
}
|
||||
//if ($this->debug) error_log(" _connectionID after: ".serialize($this->_connectionID));
|
||||
//if ($this->debug) error_log("<hr>defined functions: <pre>".var_export(get_defined_functions(),true)."</pre>");
|
||||
//if ($this->debug) ADOConnection::outp(" _connectionID after: ".serialize($this->_connectionID));
|
||||
//if ($this->debug) ADOConnection::outp("<hr>defined functions: <pre>".var_export(get_defined_functions(),true)."</pre>");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -558,12 +564,12 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
function _query($sql,$inputarr=false)
|
||||
{
|
||||
$this->_errorMsg = false;
|
||||
|
||||
|
||||
if (is_array($sql)) $sql = $sql[1];
|
||||
|
||||
|
||||
$insert = false;
|
||||
// handle native driver flaw for retrieving the last insert ID
|
||||
if(preg_match('/^\W*(insert [^;]+);?$/i', $sql)) {
|
||||
if(preg_match('/^\W*insert\s(?:(?:(?:\'\')*\'[^\']+\'(?:\'\')*)|[^;\'])*;?$/i', $sql)) {
|
||||
$insert = true;
|
||||
$sql .= '; '.$this->identitySQL; // select scope_identity()
|
||||
}
|
||||
@@ -573,15 +579,16 @@ class ADODB_mssqlnative extends ADOConnection {
|
||||
$rez = sqlsrv_query($this->_connectionID,$sql);
|
||||
}
|
||||
|
||||
if ($this->debug) error_log("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));
|
||||
if ($this->debug) ADOConnection::outp("<hr>running query: ".var_export($sql,true)."<hr>input array: ".var_export($inputarr,true)."<hr>result: ".var_export($rez,true));
|
||||
|
||||
if(!$rez) {
|
||||
$rez = false;
|
||||
} else if ($insert) {
|
||||
// retrieve the last insert ID (where applicable)
|
||||
sqlsrv_next_result($rez);
|
||||
sqlsrv_fetch($rez);
|
||||
$this->lastInsertID = sqlsrv_get_field($rez, 0);
|
||||
while ( sqlsrv_next_result($rez) ) {
|
||||
sqlsrv_fetch($rez);
|
||||
$this->lastInsertID = sqlsrv_get_field($rez, 0);
|
||||
}
|
||||
}
|
||||
return $rez;
|
||||
}
|
||||
@@ -837,7 +844,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
var $fieldOffset = 0;
|
||||
// _mths works only in non-localised system
|
||||
|
||||
function ADORecordset_mssqlnative($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -845,21 +852,21 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
|
||||
}
|
||||
$this->fetchMode = $mode;
|
||||
return $this->ADORecordSet($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
|
||||
function _initrs()
|
||||
{
|
||||
global $ADODB_COUNTRECS;
|
||||
# KMN # if ($this->connection->debug) error_log("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
|
||||
# KMN # if ($this->connection->debug) ADOConnection::outp("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
|
||||
/*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results."
|
||||
error_log("rowsaff: ".serialize($retRowsAff));
|
||||
ADOConnection::outp("rowsaff: ".serialize($retRowsAff));
|
||||
$this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;*/
|
||||
$this->_numOfRows = -1;//not supported
|
||||
$fieldmeta = sqlsrv_field_metadata($this->_queryID);
|
||||
$this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1;
|
||||
# KMN # if ($this->connection->debug) error_log("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
|
||||
# KMN # if ($this->connection->debug) ADOConnection::outp("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
|
||||
/*
|
||||
* Copy the oracle method and cache the metadata at init time
|
||||
*/
|
||||
@@ -995,16 +1002,16 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
// speedup
|
||||
function MoveNext()
|
||||
{
|
||||
//# KMN # if ($this->connection->debug) error_log("movenext()");
|
||||
//# KMN # if ($this->connection->debug) error_log("eof (beginning): ".$this->EOF);
|
||||
//# KMN # if ($this->connection->debug) ADOConnection::outp("movenext()");
|
||||
//# KMN # if ($this->connection->debug) ADOConnection::outp("eof (beginning): ".$this->EOF);
|
||||
if ($this->EOF) return false;
|
||||
|
||||
$this->_currentRow++;
|
||||
// # KMN # if ($this->connection->debug) error_log("_currentRow: ".$this->_currentRow);
|
||||
// # KMN # if ($this->connection->debug) ADOConnection::outp("_currentRow: ".$this->_currentRow);
|
||||
|
||||
if ($this->_fetch()) return true;
|
||||
$this->EOF = true;
|
||||
//# KMN # if ($this->connection->debug) error_log("eof (end): ".$this->EOF);
|
||||
//# KMN # if ($this->connection->debug) ADOConnection::outp("eof (end): ".$this->EOF);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1014,13 +1021,13 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
// also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
|
||||
function _fetch($ignore_fields=false)
|
||||
{
|
||||
# KMN # if ($this->connection->debug) error_log("_fetch()");
|
||||
# KMN # if ($this->connection->debug) ADOConnection::outp("_fetch()");
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
if ($this->fetchMode & ADODB_FETCH_NUM) {
|
||||
//# KMN # if ($this->connection->debug) error_log("fetch mode: both");
|
||||
//# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: both");
|
||||
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH);
|
||||
} else {
|
||||
//# KMN # if ($this->connection->debug) error_log("fetch mode: assoc");
|
||||
//# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: assoc");
|
||||
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC);
|
||||
}
|
||||
|
||||
@@ -1036,7 +1043,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//# KMN # if ($this->connection->debug) error_log("fetch mode: num");
|
||||
//# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: num");
|
||||
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC);
|
||||
}
|
||||
if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based
|
||||
@@ -1048,7 +1055,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
$arrFixed[$key] = $value;
|
||||
}
|
||||
}
|
||||
//if($this->connection->debug) error_log("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true));
|
||||
//if($this->connection->debug) ADOConnection::outp("<hr>fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true));
|
||||
$this->fields = $arrFixed;
|
||||
}
|
||||
if(is_array($this->fields)) {
|
||||
@@ -1059,7 +1066,7 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
}
|
||||
}
|
||||
if($this->fields === null) $this->fields = false;
|
||||
# KMN # if ($this->connection->debug) error_log("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
|
||||
# KMN # if ($this->connection->debug) ADOConnection::outp("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
@@ -1086,9 +1093,9 @@ class ADORecordset_mssqlnative extends ADORecordSet {
|
||||
|
||||
|
||||
class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
|
||||
function ADORecordSet_array_mssqlnative($id=-1,$mode=false)
|
||||
function __construct($id=-1,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_array($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
// mssql uses a default date like Dec 30 2000 12:00AM
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
@@ -28,12 +30,7 @@ class ADODB_mssqlpo extends ADODB_mssql {
|
||||
var $databaseType = "mssqlpo";
|
||||
var $concat_operator = '||';
|
||||
|
||||
function ADODB_mssqlpo()
|
||||
{
|
||||
ADODB_mssql::ADODB_mssql();
|
||||
}
|
||||
|
||||
function PrepareSP($sql)
|
||||
function PrepareSP($sql, $param = true)
|
||||
{
|
||||
if (!$this->_has_mssql_init) {
|
||||
ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
|
||||
@@ -54,8 +51,8 @@ class ADODB_mssqlpo extends ADODB_mssql {
|
||||
|
||||
class ADORecordset_mssqlpo extends ADORecordset_mssql {
|
||||
var $databaseType = "mssqlpo";
|
||||
function ADORecordset_mssqlpo($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordset_mssql($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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 8.
|
||||
|
||||
MySQL code that does not support transactions. Use mysqlt if you need transactions.
|
||||
This driver only supports the original non-transactional MySQL driver. It
|
||||
is deprected in PHP version 5.5 and removed in PHP version 7. It is deprecated
|
||||
as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
|
||||
transactional and non-transactional updates
|
||||
|
||||
Requires mysql client. Works on Windows and Unix.
|
||||
|
||||
28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra ([email protected])
|
||||
@@ -16,7 +22,7 @@ V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserv
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
if (! defined("_ADODB_MYSQL_LAYER")) {
|
||||
define("_ADODB_MYSQL_LAYER", 1 );
|
||||
define("_ADODB_MYSQL_LAYER", 1 );
|
||||
|
||||
class ADODB_mysql extends ADOConnection {
|
||||
var $databaseType = 'mysql';
|
||||
@@ -45,28 +51,29 @@ class ADODB_mysql extends ADOConnection {
|
||||
var $nameQuote = '`'; /// string to use to quote identifiers and names
|
||||
var $compat323 = false; // true if compat with mysql 3.23
|
||||
|
||||
function ADODB_mysql()
|
||||
function __construct()
|
||||
{
|
||||
if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
|
||||
}
|
||||
|
||||
|
||||
// SetCharSet - switch the client encoding
|
||||
function SetCharSet($charset_name)
|
||||
{
|
||||
if (!function_exists('mysql_set_charset'))
|
||||
return false;
|
||||
// SetCharSet - switch the client encoding
|
||||
function SetCharSet($charset_name)
|
||||
{
|
||||
if (!function_exists('mysql_set_charset')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->charSet !== $charset_name) {
|
||||
$ok = @mysql_set_charset($charset_name,$this->_connectionID);
|
||||
if ($ok) {
|
||||
$this->charSet = $charset_name;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ($this->charSet !== $charset_name) {
|
||||
$ok = @mysql_set_charset($charset_name,$this->_connectionID);
|
||||
if ($ok) {
|
||||
$this->charSet = $charset_name;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
@@ -80,66 +87,63 @@ class ADODB_mysql extends ADOConnection {
|
||||
return " IFNULL($field, $ifNull) "; // if MySQL
|
||||
}
|
||||
|
||||
function MetaProcedures($NamePattern = false, $catalog = null, $schemaPattern = null)
|
||||
{
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
function MetaProcedures($NamePattern = false, $catalog = null, $schemaPattern = null)
|
||||
{
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
|
||||
$procedures = array ();
|
||||
$procedures = array ();
|
||||
|
||||
// get index details
|
||||
// get index details
|
||||
|
||||
$likepattern = '';
|
||||
if ($NamePattern) {
|
||||
$likepattern = " LIKE '".$NamePattern."'";
|
||||
}
|
||||
$rs = $this->Execute('SHOW PROCEDURE STATUS'.$likepattern);
|
||||
if (is_object($rs)) {
|
||||
$likepattern = '';
|
||||
if ($NamePattern) {
|
||||
$likepattern = " LIKE '".$NamePattern."'";
|
||||
}
|
||||
$rs = $this->Execute('SHOW PROCEDURE STATUS'.$likepattern);
|
||||
if (is_object($rs)) {
|
||||
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
$procedures[$row[1]] = array(
|
||||
'type' => 'PROCEDURE',
|
||||
'catalog' => '',
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
$procedures[$row[1]] = array(
|
||||
'type' => 'PROCEDURE',
|
||||
'catalog' => '',
|
||||
'schema' => '',
|
||||
'remarks' => $row[7],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
'schema' => '',
|
||||
'remarks' => $row[7],
|
||||
);
|
||||
}
|
||||
$rs = $this->Execute('SHOW FUNCTION STATUS'.$likepattern);
|
||||
if (is_object($rs)) {
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
$procedures[$row[1]] = array(
|
||||
'type' => 'FUNCTION',
|
||||
'catalog' => '',
|
||||
'schema' => '',
|
||||
'remarks' => $row[7]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
return $procedures;
|
||||
}
|
||||
|
||||
$rs = $this->Execute('SHOW FUNCTION STATUS'.$likepattern);
|
||||
if (is_object($rs)) {
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
$procedures[$row[1]] = array(
|
||||
'type' => 'FUNCTION',
|
||||
'catalog' => '',
|
||||
'schema' => '',
|
||||
'remarks' => $row[7]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
|
||||
return $procedures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of tables based on given criteria
|
||||
*
|
||||
@@ -171,54 +175,54 @@ class ADODB_mysql extends ADOConnection {
|
||||
|
||||
function MetaIndexes ($table, $primary = FALSE, $owner=false)
|
||||
{
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
|
||||
// get index details
|
||||
$rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
|
||||
// get index details
|
||||
$rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
|
||||
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
// restore fetchmode
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
if (!is_object($rs)) {
|
||||
return $false;
|
||||
}
|
||||
if (!is_object($rs)) {
|
||||
return $false;
|
||||
}
|
||||
|
||||
$indexes = array ();
|
||||
$indexes = array ();
|
||||
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
if ($primary == FALSE AND $row[2] == 'PRIMARY') {
|
||||
continue;
|
||||
}
|
||||
// parse index data into array
|
||||
while ($row = $rs->FetchRow()) {
|
||||
if ($primary == FALSE AND $row[2] == 'PRIMARY') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($indexes[$row[2]])) {
|
||||
$indexes[$row[2]] = array(
|
||||
'unique' => ($row[1] == 0),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
if (!isset($indexes[$row[2]])) {
|
||||
$indexes[$row[2]] = array(
|
||||
'unique' => ($row[1] == 0),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
|
||||
$indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
|
||||
}
|
||||
$indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
|
||||
}
|
||||
|
||||
// sort columns by order in the index
|
||||
foreach ( array_keys ($indexes) as $index )
|
||||
{
|
||||
ksort ($indexes[$index]['columns']);
|
||||
}
|
||||
// sort columns by order in the index
|
||||
foreach ( array_keys ($indexes) as $index )
|
||||
{
|
||||
ksort ($indexes[$index]['columns']);
|
||||
}
|
||||
|
||||
return $indexes;
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +239,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
if ($this->replaceQuote[0] == '\\'){
|
||||
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
|
||||
}
|
||||
return "'".str_replace("'",$this->replaceQuote,$s)."'";
|
||||
return "'".str_replace("'",$this->replaceQuote,$s)."'";
|
||||
}
|
||||
|
||||
// undo magic quotes for "
|
||||
@@ -275,13 +279,13 @@ class ADODB_mysql extends ADOConnection {
|
||||
return mysql_affected_rows($this->_connectionID);
|
||||
}
|
||||
|
||||
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
|
||||
// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
|
||||
// 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 $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
|
||||
var $_genSeqSQL = "create table if not exists %s (id int not null)";
|
||||
var $_genSeqCountSQL = "select count(*) from %s";
|
||||
var $_genSeq2SQL = "insert into %s values (%s)";
|
||||
var $_dropSeqSQL = "drop table %s";
|
||||
var $_dropSeqSQL = "drop table if exists %s";
|
||||
|
||||
function CreateSequence($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
@@ -323,7 +327,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
return $this->genID;
|
||||
}
|
||||
|
||||
function MetaDatabases()
|
||||
function MetaDatabases()
|
||||
{
|
||||
$qid = mysql_list_dbs($this->_connectionID);
|
||||
$arr = array();
|
||||
@@ -488,7 +492,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
||||
}
|
||||
|
||||
function MetaColumns($table, $normalize=true)
|
||||
function MetaColumns($table, $normalize=true)
|
||||
{
|
||||
$this->_findschema($table,$schema);
|
||||
if ($schema) {
|
||||
@@ -620,7 +624,7 @@ class ADODB_mysql extends ADOConnection {
|
||||
function ErrorNo()
|
||||
{
|
||||
if ($this->_logsql) return $this->_errorCode;
|
||||
if (empty($this->_connectionID)) return @mysql_errno();
|
||||
if (empty($this->_connectionID)) return @mysql_errno();
|
||||
else return @mysql_errno($this->_connectionID);
|
||||
}
|
||||
|
||||
@@ -652,48 +656,50 @@ class ADODB_mysql extends ADOConnection {
|
||||
|
||||
// "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx>
|
||||
function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE )
|
||||
{
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC || $this->fetchMode == ADODB_FETCH_ASSOC) $associative = true;
|
||||
|
||||
if ( !empty($owner) ) {
|
||||
$table = "$owner.$table";
|
||||
}
|
||||
$a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
|
||||
if ($associative) {
|
||||
$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
|
||||
} else $create_sql = $a_create_table[1];
|
||||
if ( !empty($owner) ) {
|
||||
$table = "$owner.$table";
|
||||
}
|
||||
$a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
|
||||
if ($associative) {
|
||||
$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
|
||||
} else {
|
||||
$create_sql = $a_create_table[1];
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
$matches = array();
|
||||
|
||||
if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
|
||||
$foreign_keys = array();
|
||||
$num_keys = count($matches[0]);
|
||||
for ( $i = 0; $i < $num_keys; $i ++ ) {
|
||||
$my_field = explode('`, `', $matches[1][$i]);
|
||||
$ref_table = $matches[2][$i];
|
||||
$ref_field = explode('`, `', $matches[3][$i]);
|
||||
if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
|
||||
$foreign_keys = array();
|
||||
$num_keys = count($matches[0]);
|
||||
for ( $i = 0; $i < $num_keys; $i ++ ) {
|
||||
$my_field = explode('`, `', $matches[1][$i]);
|
||||
$ref_table = $matches[2][$i];
|
||||
$ref_field = explode('`, `', $matches[3][$i]);
|
||||
|
||||
if ( $upper ) {
|
||||
$ref_table = strtoupper($ref_table);
|
||||
}
|
||||
if ( $upper ) {
|
||||
$ref_table = strtoupper($ref_table);
|
||||
}
|
||||
|
||||
// see https://sourceforge.net/tracker/index.php?func=detail&aid=2287278&group_id=42718&atid=433976
|
||||
if (!isset($foreign_keys[$ref_table])) {
|
||||
$foreign_keys[$ref_table] = array();
|
||||
}
|
||||
$num_fields = count($my_field);
|
||||
for ( $j = 0; $j < $num_fields; $j ++ ) {
|
||||
if ( $associative ) {
|
||||
$foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
|
||||
} else {
|
||||
$foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
$num_fields = count($my_field);
|
||||
for ( $j = 0; $j < $num_fields; $j ++ ) {
|
||||
if ( $associative ) {
|
||||
$foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
|
||||
} else {
|
||||
$foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $foreign_keys;
|
||||
}
|
||||
return $foreign_keys;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -708,7 +714,7 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
var $databaseType = "mysql";
|
||||
var $canSeek = true;
|
||||
|
||||
function ADORecordSet_mysql($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -724,7 +730,7 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
$this->fetchMode = MYSQL_BOTH; break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
@@ -744,7 +750,7 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
|
||||
if ($o) $o->binary = (strpos($f,'binary')!== false);
|
||||
}
|
||||
else { /* The $fieldOffset argument is not provided thus its -1 */
|
||||
else { /* The $fieldOffset argument is not provided thus its -1 */
|
||||
$o = @mysql_fetch_field($this->_queryID);
|
||||
//if ($o) $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com)
|
||||
$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
|
||||
@@ -753,10 +759,14 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
return $o;
|
||||
}
|
||||
|
||||
function GetRowAssoc($upper=true)
|
||||
function GetRowAssoc($upper = ADODB_ASSOC_CASE)
|
||||
{
|
||||
if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields;
|
||||
else $row = ADORecordSet::GetRowAssoc($upper);
|
||||
if ($this->fetchMode == MYSQL_ASSOC && $upper == ADODB_ASSOC_CASE_LOWER) {
|
||||
$row = $this->fields;
|
||||
}
|
||||
else {
|
||||
$row = ADORecordSet::GetRowAssoc($upper);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@@ -799,7 +809,8 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
|
||||
function _fetch()
|
||||
{
|
||||
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
|
||||
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
|
||||
$this->_updatefields();
|
||||
return is_array($this->fields);
|
||||
}
|
||||
|
||||
@@ -865,23 +876,9 @@ class ADORecordSet_mysql extends ADORecordSet{
|
||||
}
|
||||
|
||||
class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
|
||||
function ADORecordSet_ext_mysql($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
switch ($mode)
|
||||
{
|
||||
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
|
||||
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
|
||||
case ADODB_FETCH_DEFAULT:
|
||||
case ADODB_FETCH_BOTH:
|
||||
default:
|
||||
$this->fetchMode = MYSQL_BOTH; break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID,$mode);
|
||||
}
|
||||
|
||||
function MoveNext()
|
||||
@@ -890,5 +887,4 @@ class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -9,6 +11,11 @@ V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserv
|
||||
|
||||
MySQL code that supports transactions. For MySQL 3.23 or later.
|
||||
Code from James Poon <[email protected]>
|
||||
|
||||
This driver extends the deprecated mysql driver, and was originally designed to be a
|
||||
portable driver in the same manner as oci8po and mssqlpo. Its functionality
|
||||
is exactly duplicated in the mysqlt driver, which is itself deprecated.
|
||||
This driver will be removed in ADOdb version 6.0.0.
|
||||
|
||||
Requires mysql client. Works on Windows and Unix.
|
||||
*/
|
||||
@@ -25,7 +32,7 @@ class ADODB_mysqlt extends ADODB_mysql {
|
||||
var $hasTransactions = true;
|
||||
var $autoRollback = true; // apparently mysql does not autorollback properly
|
||||
|
||||
function ADODB_mysqlt()
|
||||
function __construct()
|
||||
{
|
||||
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
|
||||
}
|
||||
@@ -72,7 +79,7 @@ class ADODB_mysqlt extends ADODB_mysql {
|
||||
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
||||
var $databaseType = "mysqlt";
|
||||
|
||||
function ADORecordSet_mysqlt($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -90,7 +97,7 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
||||
}
|
||||
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function MoveNext()
|
||||
@@ -109,24 +116,9 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
||||
|
||||
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
|
||||
|
||||
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
switch ($mode)
|
||||
{
|
||||
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
|
||||
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
|
||||
|
||||
case ADODB_FETCH_DEFAULT:
|
||||
case ADODB_FETCH_BOTH:
|
||||
default:
|
||||
$this->fetchMode = MYSQL_BOTH; break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID,$mode);
|
||||
}
|
||||
|
||||
function MoveNext()
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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 8.
|
||||
|
||||
MySQL code that supports transactions. For MySQL 3.23 or later.
|
||||
Code from James Poon <[email protected]>
|
||||
This driver only supports the original MySQL driver in transactional mode. It
|
||||
is deprected in PHP version 5.5 and removed in PHP version 7. It is deprecated
|
||||
as of ADOdb version 5.20.0. Use the mysqli driver instead, which supports both
|
||||
transactional and non-transactional updates
|
||||
|
||||
Requires mysql client. Works on Windows and Unix.
|
||||
*/
|
||||
@@ -25,7 +29,7 @@ class ADODB_mysqlt extends ADODB_mysql {
|
||||
var $hasTransactions = true;
|
||||
var $autoRollback = true; // apparently mysql does not autorollback properly
|
||||
|
||||
function ADODB_mysqlt()
|
||||
function __construct()
|
||||
{
|
||||
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
|
||||
}
|
||||
@@ -89,7 +93,7 @@ class ADODB_mysqlt extends ADODB_mysql {
|
||||
class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
||||
var $databaseType = "mysqlt";
|
||||
|
||||
function ADORecordSet_mysqlt($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -107,7 +111,7 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
|
||||
}
|
||||
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function MoveNext()
|
||||
@@ -128,22 +132,7 @@ class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
|
||||
|
||||
function ADORecordSet_ext_mysqlt($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
switch ($mode)
|
||||
{
|
||||
case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
|
||||
case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
|
||||
|
||||
case ADODB_FETCH_DEFAULT:
|
||||
case ADODB_FETCH_BOTH:
|
||||
default:
|
||||
$this->fetchMode = MYSQL_BOTH; break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID,$mode);
|
||||
}
|
||||
|
||||
function MoveNext()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
|
||||
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
|
||||
Based on the previous postgres drivers.
|
||||
@@ -48,7 +50,7 @@ class ADODB_netezza extends ADODB_postgres64 {
|
||||
// http://bugs.php.net/bug.php?id=25404
|
||||
|
||||
|
||||
function ADODB_netezza()
|
||||
function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -139,31 +141,17 @@ class ADORecordSet_netezza extends ADORecordSet_postgres64
|
||||
var $databaseType = "netezza";
|
||||
var $canSeek = true;
|
||||
|
||||
function ADORecordSet_netezza($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
switch ($mode)
|
||||
{
|
||||
case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
|
||||
case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
|
||||
|
||||
case ADODB_FETCH_DEFAULT:
|
||||
case ADODB_FETCH_BOTH:
|
||||
default: $this->fetchMode = PGSQL_BOTH; break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID,$mode);
|
||||
}
|
||||
|
||||
// _initrs modified to disable blob handling
|
||||
function _initrs()
|
||||
{
|
||||
global $ADODB_COUNTRECS;
|
||||
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1;
|
||||
$this->_numOfFields = @pg_numfields($this->_queryID);
|
||||
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($this->_queryID):-1;
|
||||
$this->_numOfFields = @pg_num_fields($this->_queryID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
* @version v5.20.1 06-Dec-2015
|
||||
* @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.
|
||||
@@ -21,11 +23,6 @@ class ADODB_oci805 extends ADODB_oci8 {
|
||||
var $databaseType = "oci805";
|
||||
var $connectSID = true;
|
||||
|
||||
function ADODB_oci805()
|
||||
{
|
||||
$this->ADODB_oci8();
|
||||
}
|
||||
|
||||
function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
|
||||
{
|
||||
// seems that oracle only supports 1 hint comment in 8i
|
||||
@@ -51,8 +48,8 @@ class ADODB_oci805 extends ADODB_oci8 {
|
||||
|
||||
class ADORecordset_oci805 extends ADORecordset_oci8 {
|
||||
var $databaseType = "oci805";
|
||||
function ADORecordset_oci805($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordset_oci8($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim. All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -28,7 +30,7 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by [email protected]. 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()
|
||||
@@ -64,11 +66,22 @@ class ADODB_oci8po extends ADODB_oci8 {
|
||||
$arr['bind'.$i++] = $v;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
|
||||
$sqlarr = explode('?',$sql);
|
||||
$sql = $sqlarr[0];
|
||||
|
||||
foreach($inputarr as $k => $v) {
|
||||
$sql .= ":$k" . $sqlarr[++$i];
|
||||
}
|
||||
|
||||
$sql = str_replace('-QUESTIONMARK-', '?', $sql);
|
||||
}
|
||||
}
|
||||
return ADODB_oci8::_query($sql,$inputarr);
|
||||
@@ -83,9 +96,9 @@ 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)
|
||||
@@ -105,32 +118,22 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
// 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()
|
||||
@@ -138,8 +141,8 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
|
||||
global $ADODB_ANSI_PADDING_OFF;
|
||||
$this->_currentRow++;
|
||||
$this->_updatefields();
|
||||
|
||||
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);
|
||||
@@ -170,7 +173,7 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
$arr = array();
|
||||
return $arr;
|
||||
}
|
||||
if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
|
||||
$this->_updatefields();
|
||||
$results = array();
|
||||
$cnt = 0;
|
||||
while (!$this->EOF && $nrows != $cnt) {
|
||||
@@ -181,38 +184,19 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
|
||||
return $results;
|
||||
}
|
||||
|
||||
// Create associative array
|
||||
function _updatefields()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
$this->fields = $arr;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
$ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
|
||||
if ($ret) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim. All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -26,7 +28,7 @@ class ADODB_oci8quercus extends ADODB_oci8 {
|
||||
var $databaseType = 'oci8quercus';
|
||||
var $dataProvider = 'oci8';
|
||||
|
||||
function ADODB_oci8quercus()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,9 +42,9 @@ class ADORecordset_oci8quercus extends ADORecordset_oci8 {
|
||||
|
||||
var $databaseType = 'oci8quercus';
|
||||
|
||||
function ADORecordset_oci8quercus($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
$this->ADORecordset_oci8($queryID,$mode);
|
||||
parent::__construct($queryID,$mode);
|
||||
}
|
||||
|
||||
function _FetchField($fieldOffset = -1)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -39,7 +41,7 @@ class ADODB_odbc extends ADOConnection {
|
||||
var $_lastAffectedRows = 0;
|
||||
var $uCaseTables = true; // for meta* functions, uppercase table names
|
||||
|
||||
function ADODB_odbc()
|
||||
function __construct()
|
||||
{
|
||||
$this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
|
||||
$this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
|
||||
@@ -132,7 +134,7 @@ class ADODB_odbc extends ADOConnection {
|
||||
}
|
||||
|
||||
var $_dropSeqSQL = 'drop table %s';
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
if (empty($this->_dropSeqSQL)) return false;
|
||||
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
|
||||
@@ -606,7 +608,7 @@ class ADORecordSet_odbc extends ADORecordSet {
|
||||
var $useFetchArray;
|
||||
var $_has_stupid_odbc_fetch_api_change;
|
||||
|
||||
function ADORecordSet_odbc($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -619,7 +621,7 @@ class ADORecordSet_odbc extends ADORecordSet {
|
||||
// the following is required for mysql odbc driver in 4.3.1 -- why?
|
||||
$this->EOF = false;
|
||||
$this->_currentRow = -1;
|
||||
//$this->ADORecordSet($id);
|
||||
//parent::__construct($id);
|
||||
}
|
||||
|
||||
|
||||
@@ -683,7 +685,7 @@ class ADORecordSet_odbc extends ADORecordSet {
|
||||
$this->fetchMode = $savem;
|
||||
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
|
||||
$results = array();
|
||||
@@ -721,7 +723,7 @@ class ADORecordSet_odbc extends ADORecordSet {
|
||||
}
|
||||
if ($rez) {
|
||||
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -110,10 +112,10 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
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 )
|
||||
@@ -278,7 +280,7 @@ class ADODB_ODBC_DB2 extends ADODB_odbc {
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
@@ -304,9 +306,9 @@ class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = "db2";
|
||||
|
||||
function ADORecordSet_db2($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_odbc($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -45,9 +47,9 @@ class ADODB_odbc_mssql extends ADODB_odbc {
|
||||
var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON,
|
||||
# concatenating a null value with a string yields a NULL result
|
||||
|
||||
function ADODB_odbc_mssql()
|
||||
function __construct()
|
||||
{
|
||||
$this->ADODB_odbc();
|
||||
parent::__construct();
|
||||
//$this->curmode = SQL_CUR_USE_ODBC;
|
||||
}
|
||||
|
||||
@@ -252,7 +254,7 @@ order by constraint_name, referenced_table_name, keyno";
|
||||
|
||||
// "Stein-Aksel Basma" <[email protected]>
|
||||
// tested with MSSQL 2000
|
||||
function MetaPrimaryKeys($table)
|
||||
function MetaPrimaryKeys($table, $owner = false)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
@@ -354,8 +356,8 @@ class ADORecordSet_odbc_mssql extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = 'odbc_mssql';
|
||||
|
||||
function ADORecordSet_odbc_mssql($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbc($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -31,12 +33,7 @@ class ADODB_odbc_oracle extends ADODB_odbc {
|
||||
|
||||
//var $_bindInputArray = false;
|
||||
|
||||
function ADODB_odbc_oracle()
|
||||
{
|
||||
$this->ADODB_odbc();
|
||||
}
|
||||
|
||||
function MetaTables()
|
||||
function MetaTables($ttype = false, $showSchema = false, $mask = false)
|
||||
{
|
||||
$false = false;
|
||||
$rs = $this->Execute($this->metaTablesSQL);
|
||||
@@ -107,8 +104,8 @@ class ADORecordSet_odbc_oracle extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = 'odbc_oracle';
|
||||
|
||||
function ADORecordSet_odbc_oracle($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbc($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -33,7 +35,7 @@ class ADODB_odbtp extends ADOConnection{
|
||||
var $_canPrepareSP = false;
|
||||
var $_dontPoolDBC = true;
|
||||
|
||||
function ADODB_odbtp()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -120,7 +122,7 @@ class ADODB_odbtp extends ADOConnection{
|
||||
return $this->Execute("insert into adodb_seq values('$seqname',$start)");
|
||||
}
|
||||
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
if (empty($this->_dropSeqSQL)) return false;
|
||||
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
|
||||
@@ -475,7 +477,7 @@ class ADODB_odbtp extends ADOConnection{
|
||||
return array($sql,$stmt,false);
|
||||
}
|
||||
|
||||
function PrepareSP($sql)
|
||||
function PrepareSP($sql, $param = true)
|
||||
{
|
||||
if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures
|
||||
|
||||
@@ -668,14 +670,14 @@ class ADORecordSet_odbtp extends ADORecordSet {
|
||||
var $databaseType = 'odbtp';
|
||||
var $canSeek = true;
|
||||
|
||||
function ADORecordSet_odbtp($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
$this->fetchMode = $mode;
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
@@ -791,9 +793,9 @@ class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {
|
||||
|
||||
var $databaseType = 'odbtp_mssql';
|
||||
|
||||
function ADORecordSet_odbtp_mssql($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbtp($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,9 +803,9 @@ class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {
|
||||
|
||||
var $databaseType = 'odbtp_access';
|
||||
|
||||
function ADORecordSet_odbtp_access($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbtp($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,9 +813,9 @@ class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {
|
||||
|
||||
var $databaseType = 'odbtp_vfp';
|
||||
|
||||
function ADORecordSet_odbtp_vfp($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbtp($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,9 +823,9 @@ class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {
|
||||
|
||||
var $databaseType = 'odbtp_oci8';
|
||||
|
||||
function ADORecordSet_odbtp_oci8($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbtp($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,8 +833,8 @@ class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {
|
||||
|
||||
var $databaseType = 'odbtp_sybase';
|
||||
|
||||
function ADORecordSet_odbtp_sybase($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbtp($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -30,9 +32,4 @@ if (!defined('_ADODB_ODBTP_LAYER')) {
|
||||
class ADODB_odbtp_unicode extends ADODB_odbtp {
|
||||
var $databaseType = 'odbtp';
|
||||
var $_useUnicodeSQL = true;
|
||||
|
||||
function ADODB_odbtp_unicode()
|
||||
{
|
||||
$this->ADODB_odbtp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -27,12 +29,12 @@ class ADODB_oracle extends ADOConnection {
|
||||
var $sysTimeStamp = 'SYSDATE';
|
||||
var $connectSID = true;
|
||||
|
||||
function ADODB_oracle()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
// format and return date string in database date format
|
||||
function DBDate($d)
|
||||
function DBDate($d, $isfld = false)
|
||||
{
|
||||
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
|
||||
if (is_object($d)) $ds = $d->format($this->fmtDate);
|
||||
@@ -41,7 +43,7 @@ class ADODB_oracle extends ADOConnection {
|
||||
}
|
||||
|
||||
// format and return date string in database timestamp format
|
||||
function DBTimeStamp($ts)
|
||||
function DBTimeStamp($ts, $isfld = false)
|
||||
{
|
||||
|
||||
if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
|
||||
@@ -219,7 +221,7 @@ class ADORecordset_oracle extends ADORecordSet {
|
||||
var $databaseType = "oracle";
|
||||
var $bind = false;
|
||||
|
||||
function ADORecordset_oracle($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
|
||||
if ($mode === false) {
|
||||
@@ -303,7 +305,7 @@ class ADORecordset_oracle extends ADORecordSet {
|
||||
return @ora_close($this->_queryID);
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1)
|
||||
function MetaType($t, $len = -1, $fieldobj = false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
|
||||
+235
-102
@@ -1,19 +1,24 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 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.
|
||||
Set tabs to 4 for best viewing.
|
||||
/**
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
|
||||
Latest version is available at http://adodb.sourceforge.net
|
||||
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.
|
||||
|
||||
Requires ODBC. Works on Windows and Unix.
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
Latest version is available at http://adodb.sourceforge.net
|
||||
|
||||
Requires ODBC. Works on Windows and Unix.
|
||||
|
||||
Problems:
|
||||
Where is float/decimal type in pdo_param_type
|
||||
LOB handling for CLOB/BLOB differs significantly
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
@@ -57,14 +62,7 @@ function adodb_pdo_type($t)
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
class ADODB_pdo extends ADOConnection {
|
||||
@@ -75,7 +73,9 @@ class ADODB_pdo extends ADOConnection {
|
||||
var $replaceQuote = "''"; // string to use to replace quotes
|
||||
var $hasAffectedRows = true;
|
||||
var $_bindInputArray = true;
|
||||
var $_genIDSQL;
|
||||
var $_genSeqSQL = "create table %s (id integer)";
|
||||
var $_dropSeqSQL;
|
||||
var $_autocommit = true;
|
||||
var $_haserrorfunctions = true;
|
||||
var $_lastAffectedRows = 0;
|
||||
@@ -85,8 +85,9 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
var $dsnType = '';
|
||||
var $stmt = false;
|
||||
var $_driver;
|
||||
|
||||
function ADODB_pdo()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -112,11 +113,17 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
function Time()
|
||||
{
|
||||
if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual";
|
||||
else $sql = "select $this->sysTimeStamp";
|
||||
if (!empty($this->_driver->_hasdual)) {
|
||||
$sql = "select $this->sysTimeStamp from dual";
|
||||
}
|
||||
else {
|
||||
$sql = "select $this->sysTimeStamp";
|
||||
}
|
||||
|
||||
$rs = $this->_Execute($sql);
|
||||
if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
|
||||
if ($rs && !$rs->EOF) {
|
||||
return $this->UnixTimeStamp(reset($rs->fields));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -128,7 +135,18 @@ class ADODB_pdo extends ADOConnection {
|
||||
$this->dsnType = substr($argDSN,0,$at);
|
||||
|
||||
if ($argDatabasename) {
|
||||
$argDSN .= ';dbname='.$argDatabasename;
|
||||
switch($this->dsnType){
|
||||
case 'sqlsrv':
|
||||
$argDSN .= ';database='.$argDatabasename;
|
||||
break;
|
||||
case 'mssql':
|
||||
case 'mysql':
|
||||
case 'oci':
|
||||
case 'pgsql':
|
||||
case 'sqlite':
|
||||
default:
|
||||
$argDSN .= ';dbname='.$argDatabasename;
|
||||
}
|
||||
}
|
||||
try {
|
||||
$this->_connectionID = new PDO($argDSN, $argUsername, $argPassword);
|
||||
@@ -142,10 +160,16 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
if ($this->_connectionID) {
|
||||
switch(ADODB_ASSOC_CASE){
|
||||
case 0: $m = PDO::CASE_LOWER; break;
|
||||
case 1: $m = PDO::CASE_UPPER; break;
|
||||
default:
|
||||
case 2: $m = PDO::CASE_NATURAL; break;
|
||||
case ADODB_ASSOC_CASE_LOWER:
|
||||
$m = PDO::CASE_LOWER;
|
||||
break;
|
||||
case ADODB_ASSOC_CASE_UPPER:
|
||||
$m = PDO::CASE_UPPER;
|
||||
break;
|
||||
default:
|
||||
case ADODB_ASSOC_CASE_NATIVE:
|
||||
$m = PDO::CASE_NATURAL;
|
||||
break;
|
||||
}
|
||||
|
||||
//$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT );
|
||||
@@ -154,18 +178,21 @@ class ADODB_pdo extends ADOConnection {
|
||||
$class = 'ADODB_pdo_'.$this->dsnType;
|
||||
//$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true);
|
||||
switch($this->dsnType) {
|
||||
case 'oci':
|
||||
case 'mysql':
|
||||
case 'pgsql':
|
||||
case 'mssql':
|
||||
case 'sqlite':
|
||||
include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php');
|
||||
break;
|
||||
case 'mssql':
|
||||
case 'mysql':
|
||||
case 'oci':
|
||||
case 'pgsql':
|
||||
case 'sqlite':
|
||||
case 'sqlsrv':
|
||||
include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php');
|
||||
break;
|
||||
}
|
||||
if (class_exists($class))
|
||||
if (class_exists($class)) {
|
||||
$this->_driver = new $class();
|
||||
else
|
||||
}
|
||||
else {
|
||||
$this->_driver = new ADODB_pdo_base();
|
||||
}
|
||||
|
||||
$this->_driver->_connectionID = $this->_connectionID;
|
||||
$this->_UpdatePDO();
|
||||
@@ -178,10 +205,13 @@ class ADODB_pdo extends ADOConnection {
|
||||
function Concat()
|
||||
{
|
||||
$args = func_get_args();
|
||||
if(method_exists($this->_driver, 'Concat'))
|
||||
if(method_exists($this->_driver, 'Concat')) {
|
||||
return call_user_func_array(array($this->_driver, 'Concat'), $args);
|
||||
}
|
||||
|
||||
if (PHP_VERSION >= 5.3) return call_user_func_array('parent::Concat', $args);
|
||||
if (PHP_VERSION >= 5.3) {
|
||||
return call_user_func_array('parent::Concat', $args);
|
||||
}
|
||||
return call_user_func_array(array($this,'parent::Concat'), $args);
|
||||
}
|
||||
|
||||
@@ -198,7 +228,7 @@ class ADODB_pdo extends ADOConnection {
|
||||
{
|
||||
$save = $this->_driver->fetchMode;
|
||||
$this->_driver->fetchMode = $this->fetchMode;
|
||||
$this->_driver->debug = $this->debug;
|
||||
$this->_driver->debug = $this->debug;
|
||||
$ret = $this->_driver->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
|
||||
$this->_driver->fetchMode = $save;
|
||||
return $ret;
|
||||
@@ -223,76 +253,123 @@ class ADODB_pdo extends ADOConnection {
|
||||
function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
|
||||
{
|
||||
$obj = $stmt[1];
|
||||
if ($type) $obj->bindParam($name,$var,$type,$maxLen);
|
||||
else $obj->bindParam($name, $var);
|
||||
if ($type) {
|
||||
$obj->bindParam($name, $var, $type, $maxLen);
|
||||
}
|
||||
else {
|
||||
$obj->bindParam($name, $var);
|
||||
}
|
||||
}
|
||||
|
||||
function OffsetDate($dayFraction,$date=false)
|
||||
{
|
||||
return $this->_driver->OffsetDate($dayFraction,$date);
|
||||
}
|
||||
{
|
||||
return $this->_driver->OffsetDate($dayFraction,$date);
|
||||
}
|
||||
|
||||
function ErrorMsg()
|
||||
{
|
||||
if ($this->_errormsg !== false) return $this->_errormsg;
|
||||
if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo();
|
||||
else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo();
|
||||
else return 'No Connection Established';
|
||||
|
||||
if ($this->_errormsg !== false) {
|
||||
return $this->_errormsg;
|
||||
}
|
||||
if (!empty($this->_stmt)) {
|
||||
$arr = $this->_stmt->errorInfo();
|
||||
}
|
||||
else if (!empty($this->_connectionID)) {
|
||||
$arr = $this->_connectionID->errorInfo();
|
||||
}
|
||||
else {
|
||||
return 'No Connection Established';
|
||||
}
|
||||
|
||||
if ($arr) {
|
||||
if (sizeof($arr)<2) return '';
|
||||
if ((integer)$arr[0]) return $arr[2];
|
||||
else return '';
|
||||
} else return '-1';
|
||||
if (sizeof($arr)<2) {
|
||||
return '';
|
||||
}
|
||||
if ((integer)$arr[0]) {
|
||||
return $arr[2];
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
return '-1';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ErrorNo()
|
||||
{
|
||||
if ($this->_errorno !== false) return $this->_errorno;
|
||||
if (!empty($this->_stmt)) $err = $this->_stmt->errorCode();
|
||||
if ($this->_errorno !== false) {
|
||||
return $this->_errorno;
|
||||
}
|
||||
if (!empty($this->_stmt)) {
|
||||
$err = $this->_stmt->errorCode();
|
||||
}
|
||||
else if (!empty($this->_connectionID)) {
|
||||
$arr = $this->_connectionID->errorInfo();
|
||||
if (isset($arr[0])) $err = $arr[0];
|
||||
else $err = -1;
|
||||
} else
|
||||
if (isset($arr[0])) {
|
||||
$err = $arr[0];
|
||||
}
|
||||
else {
|
||||
$err = -1;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($err == '00000') return 0; // allows empty check
|
||||
if ($err == '00000') {
|
||||
return 0; // allows empty check
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
function SetTransactionMode($transaction_mode)
|
||||
{
|
||||
if(method_exists($this->_driver, 'SetTransactionMode'))
|
||||
if(method_exists($this->_driver, 'SetTransactionMode')) {
|
||||
return $this->_driver->SetTransactionMode($transaction_mode);
|
||||
}
|
||||
|
||||
return parent::SetTransactionMode($seqname);
|
||||
}
|
||||
|
||||
function BeginTrans()
|
||||
{
|
||||
if(method_exists($this->_driver, 'BeginTrans'))
|
||||
if(method_exists($this->_driver, 'BeginTrans')) {
|
||||
return $this->_driver->BeginTrans();
|
||||
}
|
||||
|
||||
if (!$this->hasTransactions) return false;
|
||||
if ($this->transOff) return true;
|
||||
if (!$this->hasTransactions) {
|
||||
return false;
|
||||
}
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
$this->transCnt += 1;
|
||||
$this->_autocommit = false;
|
||||
$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,false);
|
||||
|
||||
return $this->_connectionID->beginTransaction();
|
||||
}
|
||||
|
||||
function CommitTrans($ok=true)
|
||||
{
|
||||
if(method_exists($this->_driver, 'CommitTrans'))
|
||||
if(method_exists($this->_driver, 'CommitTrans')) {
|
||||
return $this->_driver->CommitTrans($ok);
|
||||
}
|
||||
|
||||
if (!$this->hasTransactions) return false;
|
||||
if ($this->transOff) return true;
|
||||
if (!$ok) return $this->RollbackTrans();
|
||||
if ($this->transCnt) $this->transCnt -= 1;
|
||||
if (!$this->hasTransactions) {
|
||||
return false;
|
||||
}
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
if (!$ok) {
|
||||
return $this->RollbackTrans();
|
||||
}
|
||||
if ($this->transCnt) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
$this->_autocommit = true;
|
||||
|
||||
$ret = $this->_connectionID->commit();
|
||||
@@ -302,12 +379,19 @@ class ADODB_pdo extends ADOConnection {
|
||||
|
||||
function RollbackTrans()
|
||||
{
|
||||
if(method_exists($this->_driver, 'RollbackTrans'))
|
||||
if(method_exists($this->_driver, 'RollbackTrans')) {
|
||||
return $this->_driver->RollbackTrans();
|
||||
}
|
||||
|
||||
if (!$this->hasTransactions) return false;
|
||||
if ($this->transOff) return true;
|
||||
if ($this->transCnt) $this->transCnt -= 1;
|
||||
if (!$this->hasTransactions) {
|
||||
return false;
|
||||
}
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
if ($this->transCnt) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
$this->_autocommit = true;
|
||||
|
||||
$ret = $this->_connectionID->rollback();
|
||||
@@ -318,7 +402,9 @@ class ADODB_pdo extends ADOConnection {
|
||||
function Prepare($sql)
|
||||
{
|
||||
$this->_stmt = $this->_connectionID->prepare($sql);
|
||||
if ($this->_stmt) return array($sql,$this->_stmt);
|
||||
if ($this->_stmt) {
|
||||
return array($sql,$this->_stmt);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -326,31 +412,36 @@ class ADODB_pdo extends ADOConnection {
|
||||
function PrepareStmt($sql)
|
||||
{
|
||||
$stmt = $this->_connectionID->prepare($sql);
|
||||
if (!$stmt) return false;
|
||||
if (!$stmt) {
|
||||
return false;
|
||||
}
|
||||
$obj = new ADOPDOStatement($stmt,$this);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function CreateSequence($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
if(method_exists($this->_driver, 'CreateSequence'))
|
||||
if(method_exists($this->_driver, 'CreateSequence')) {
|
||||
return $this->_driver->CreateSequence($seqname, $startID);
|
||||
}
|
||||
|
||||
return parent::CreateSequence($seqname, $startID);
|
||||
}
|
||||
|
||||
function DropSequence($seqname='adodbseq')
|
||||
{
|
||||
if(method_exists($this->_driver, 'DropSequence'))
|
||||
if(method_exists($this->_driver, 'DropSequence')) {
|
||||
return $this->_driver->DropSequence($seqname);
|
||||
}
|
||||
|
||||
return parent::DropSequence($seqname);
|
||||
}
|
||||
|
||||
function GenID($seqname='adodbseq',$startID=1)
|
||||
{
|
||||
if(method_exists($this->_driver, 'GenID'))
|
||||
if(method_exists($this->_driver, 'GenID')) {
|
||||
return $this->_driver->GenID($seqname, $startID);
|
||||
}
|
||||
|
||||
return parent::GenID($seqname, $startID);
|
||||
}
|
||||
@@ -368,8 +459,12 @@ class ADODB_pdo extends ADOConnection {
|
||||
#var_dump($this->_bindInputArray);
|
||||
if ($stmt) {
|
||||
$this->_driver->debug = $this->debug;
|
||||
if ($inputarr) $ok = $stmt->execute($inputarr);
|
||||
else $ok = $stmt->execute();
|
||||
if ($inputarr) {
|
||||
$ok = $stmt->execute($inputarr);
|
||||
}
|
||||
else {
|
||||
$ok = $stmt->execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -437,12 +532,12 @@ class ADODB_pdo_base extends ADODB_pdo {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function MetaTables()
|
||||
function MetaTables($ttype=false,$showSchema=false,$mask=false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function MetaColumns()
|
||||
function MetaColumns($table,$normalize=true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -455,7 +550,7 @@ class ADOPDOStatement {
|
||||
var $_stmt;
|
||||
var $_connectionID;
|
||||
|
||||
function ADOPDOStatement($stmt,$connection)
|
||||
function __construct($stmt,$connection)
|
||||
{
|
||||
$this->_stmt = $stmt;
|
||||
$this->_connectionID = $connection;
|
||||
@@ -472,8 +567,12 @@ class ADOPDOStatement {
|
||||
function InParameter(&$var,$name,$maxLen=4000,$type=false)
|
||||
{
|
||||
|
||||
if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen);
|
||||
else $this->_stmt->bindParam($name, $var);
|
||||
if ($type) {
|
||||
$this->_stmt->bindParam($name,$var,$type,$maxLen);
|
||||
}
|
||||
else {
|
||||
$this->_stmt->bindParam($name, $var);
|
||||
}
|
||||
}
|
||||
|
||||
function Affected_Rows()
|
||||
@@ -483,13 +582,23 @@ class ADOPDOStatement {
|
||||
|
||||
function ErrorMsg()
|
||||
{
|
||||
if ($this->_stmt) $arr = $this->_stmt->errorInfo();
|
||||
else $arr = $this->_connectionID->errorInfo();
|
||||
if ($this->_stmt) {
|
||||
$arr = $this->_stmt->errorInfo();
|
||||
}
|
||||
else {
|
||||
$arr = $this->_connectionID->errorInfo();
|
||||
}
|
||||
|
||||
if (is_array($arr)) {
|
||||
if ((integer) $arr[0] && isset($arr[2])) return $arr[2];
|
||||
else return '';
|
||||
} else return '-1';
|
||||
if ((integer) $arr[0] && isset($arr[2])) {
|
||||
return $arr[2];
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '-1';
|
||||
}
|
||||
}
|
||||
|
||||
function NumCols()
|
||||
@@ -499,13 +608,17 @@ class ADOPDOStatement {
|
||||
|
||||
function ErrorNo()
|
||||
{
|
||||
if ($this->_stmt) return $this->_stmt->errorCode();
|
||||
else return $this->_connectionID->errorInfo();
|
||||
if ($this->_stmt) {
|
||||
return $this->_stmt->errorCode();
|
||||
}
|
||||
else {
|
||||
return $this->_connectionID->errorInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
class ADORecordSet_pdo extends ADORecordSet {
|
||||
@@ -514,7 +627,7 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
var $databaseType = "pdo";
|
||||
var $dataProvider = "pdo";
|
||||
|
||||
function ADORecordSet_pdo($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -531,15 +644,19 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
$this->fetchMode = $mode;
|
||||
|
||||
$this->_queryID = $id;
|
||||
$this->ADORecordSet($id);
|
||||
parent::__construct($id);
|
||||
}
|
||||
|
||||
|
||||
function Init()
|
||||
{
|
||||
if ($this->_inited) return;
|
||||
if ($this->_inited) {
|
||||
return;
|
||||
}
|
||||
$this->_inited = true;
|
||||
if ($this->_queryID) @$this->_initrs();
|
||||
if ($this->_queryID) {
|
||||
@$this->_initrs();
|
||||
}
|
||||
else {
|
||||
$this->_numOfRows = 0;
|
||||
$this->_numOfFields = 0;
|
||||
@@ -559,7 +676,9 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
global $ADODB_COUNTRECS;
|
||||
|
||||
$this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1;
|
||||
if (!$this->_numOfRows) $this->_numOfRows = -1;
|
||||
if (!$this->_numOfRows) {
|
||||
$this->_numOfRows = -1;
|
||||
}
|
||||
$this->_numOfFields = $this->_queryID->columnCount();
|
||||
}
|
||||
|
||||
@@ -580,13 +699,23 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
}
|
||||
//adodb_pr($arr);
|
||||
$o->name = $arr['name'];
|
||||
if (isset($arr['native_type']) && $arr['native_type'] <> "null") $o->type = $arr['native_type'];
|
||||
else $o->type = adodb_pdo_type($arr['pdo_type']);
|
||||
if (isset($arr['native_type']) && $arr['native_type'] <> "null") {
|
||||
$o->type = $arr['native_type'];
|
||||
}
|
||||
else {
|
||||
$o->type = adodb_pdo_type($arr['pdo_type']);
|
||||
}
|
||||
$o->max_length = $arr['len'];
|
||||
$o->precision = $arr['precision'];
|
||||
|
||||
if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
|
||||
else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
|
||||
switch(ADODB_ASSOC_CASE) {
|
||||
case ADODB_ASSOC_CASE_LOWER:
|
||||
$o->name = strtolower($o->name);
|
||||
break;
|
||||
case ADODB_ASSOC_CASE_UPPER:
|
||||
$o->name = strtoupper($o->name);
|
||||
break;
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
@@ -597,7 +726,9 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
|
||||
function _fetch()
|
||||
{
|
||||
if (!$this->_queryID) return false;
|
||||
if (!$this->_queryID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->fields = $this->_queryID->fetch($this->fetchMode);
|
||||
return !empty($this->fields);
|
||||
@@ -610,7 +741,9 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
|
||||
function Fields($colname)
|
||||
{
|
||||
if ($this->adodbFetchMode != ADODB_FETCH_NUM) return @$this->fields[$colname];
|
||||
if ($this->adodbFetchMode != ADODB_FETCH_NUM) {
|
||||
return @$this->fields[$colname];
|
||||
}
|
||||
|
||||
if (!$this->bind) {
|
||||
$this->bind = array();
|
||||
@@ -619,7 +752,7 @@ class ADORecordSet_pdo extends ADORecordSet {
|
||||
$this->bind[strtoupper($o->name)] = $i;
|
||||
}
|
||||
}
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -11,7 +11,12 @@ V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserv
|
||||
*/
|
||||
|
||||
class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
var $metaTablesSQL = "SHOW TABLES";
|
||||
|
||||
var $metaTablesSQL = "SELECT
|
||||
TABLE_NAME,
|
||||
CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA=";
|
||||
var $metaColumnsSQL = "SHOW COLUMNS FROM `%s`";
|
||||
var $sysDate = 'CURDATE()';
|
||||
var $sysTimeStamp = 'NOW()';
|
||||
@@ -23,42 +28,45 @@ class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
|
||||
function _init($parentDriver)
|
||||
{
|
||||
|
||||
$parentDriver->hasTransactions = false;
|
||||
#$parentDriver->_bindInputArray = false;
|
||||
$parentDriver->hasInsertID = true;
|
||||
$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
|
||||
$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
|
||||
}
|
||||
|
||||
// dayFraction is a day in floating point
|
||||
function OffsetDate($dayFraction,$date=false)
|
||||
// dayFraction is a day in floating point
|
||||
function OffsetDate($dayFraction, $date=false)
|
||||
{
|
||||
if (!$date) $date = $this->sysDate;
|
||||
if (!$date) {
|
||||
$date = $this->sysDate;
|
||||
}
|
||||
|
||||
$fraction = $dayFraction * 24 * 3600;
|
||||
return $date . ' + INTERVAL ' . $fraction.' SECOND';
|
||||
|
||||
return $date . ' + INTERVAL ' . $fraction . ' SECOND';
|
||||
// return "from_unixtime(unix_timestamp($date)+$fraction)";
|
||||
}
|
||||
|
||||
function Concat()
|
||||
{
|
||||
$s = "";
|
||||
$s = '';
|
||||
$arr = func_get_args();
|
||||
|
||||
// suggestion by andrew005#mnogo.ru
|
||||
$s = implode(',',$arr);
|
||||
if (strlen($s) > 0) return "CONCAT($s)"; return '';
|
||||
$s = implode(',', $arr);
|
||||
if (strlen($s) > 0) {
|
||||
return "CONCAT($s)";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
$arr['description'] = ADOConnection::GetOne("select version()");
|
||||
$arr['description'] = ADOConnection::GetOne('select version()');
|
||||
$arr['version'] = ADOConnection::_findvers($arr['description']);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function MetaTables($ttype=false,$showSchema=false,$mask=false)
|
||||
function MetaTables($ttype=false, $showSchema=false, $mask=false)
|
||||
{
|
||||
$save = $this->metaTablesSQL;
|
||||
if ($showSchema && is_string($showSchema)) {
|
||||
@@ -69,26 +77,28 @@ class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
$mask = $this->qstr($mask);
|
||||
$this->metaTablesSQL .= " like $mask";
|
||||
}
|
||||
$ret = ADOConnection::MetaTables($ttype,$showSchema);
|
||||
$ret = ADOConnection::MetaTables($ttype, $showSchema);
|
||||
|
||||
$this->metaTablesSQL = $save;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function SetTransactionMode( $transaction_mode )
|
||||
function SetTransactionMode($transaction_mode)
|
||||
{
|
||||
$this->_transmode = $transaction_mode;
|
||||
if (empty($transaction_mode)) {
|
||||
$this->Execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ');
|
||||
return;
|
||||
}
|
||||
if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
|
||||
$this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
|
||||
if (!stristr($transaction_mode, 'isolation')) {
|
||||
$transaction_mode = 'ISOLATION LEVEL ' . $transaction_mode;
|
||||
}
|
||||
$this->Execute('SET SESSION TRANSACTION ' . $transaction_mode);
|
||||
}
|
||||
|
||||
function MetaColumns($table,$normalize=true)
|
||||
function MetaColumns($table, $normalize=true)
|
||||
{
|
||||
$this->_findschema($table,$schema);
|
||||
$this->_findschema($table, $schema);
|
||||
if ($schema) {
|
||||
$dbName = $this->database;
|
||||
$this->SelectDB($schema);
|
||||
@@ -97,14 +107,18 @@ class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
|
||||
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
|
||||
$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
|
||||
if ($this->fetchMode !== false) {
|
||||
$savem = $this->SetFetchMode(false);
|
||||
}
|
||||
$rs = $this->Execute(sprintf($this->metaColumnsSQL, $table));
|
||||
|
||||
if ($schema) {
|
||||
$this->SelectDB($dbName);
|
||||
}
|
||||
|
||||
if (isset($savem)) $this->SetFetchMode($savem);
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
if (!is_object($rs)) {
|
||||
$false = false;
|
||||
@@ -119,18 +133,18 @@ class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
|
||||
// split type into type(length):
|
||||
$fld->scale = null;
|
||||
if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
|
||||
if (preg_match('/^(.+)\((\d+),(\d+)/', $type, $query_array)) {
|
||||
$fld->type = $query_array[1];
|
||||
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
|
||||
$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
|
||||
} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
|
||||
} elseif (preg_match('/^(.+)\((\d+)/', $type, $query_array)) {
|
||||
$fld->type = $query_array[1];
|
||||
$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
|
||||
} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
|
||||
} elseif (preg_match('/^(enum)\((.*)\)$/i', $type, $query_array)) {
|
||||
$fld->type = $query_array[1];
|
||||
$arr = explode(",",$query_array[2]);
|
||||
$arr = explode(',', $query_array[2]);
|
||||
$fld->enums = $arr;
|
||||
$zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
|
||||
$zlen = max(array_map('strlen', $arr)) - 2; // PHP >= 4.0.6
|
||||
$fld->max_length = ($zlen > 0) ? $zlen : 1;
|
||||
} else {
|
||||
$fld->type = $type;
|
||||
@@ -139,8 +153,8 @@ class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
$fld->not_null = ($rs->fields[2] != 'YES');
|
||||
$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->binary = (strpos($type, 'blob') !== false);
|
||||
$fld->unsigned = (strpos($type, 'unsigned') !== false);
|
||||
|
||||
if (!$fld->binary) {
|
||||
$d = $rs->fields[4];
|
||||
@@ -157,25 +171,130 @@ class ADODB_pdo_mysql extends ADODB_pdo {
|
||||
} else {
|
||||
$retarr[strtoupper($fld->name)] = $fld;
|
||||
}
|
||||
$rs->MoveNext();
|
||||
}
|
||||
$rs->MoveNext();
|
||||
}
|
||||
|
||||
$rs->Close();
|
||||
return $retarr;
|
||||
$rs->Close();
|
||||
return $retarr;
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function SelectDB($dbName)
|
||||
{
|
||||
$this->database = $dbName;
|
||||
$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
|
||||
$try = $this->Execute('use ' . $dbName);
|
||||
return ($try !== false);
|
||||
}
|
||||
|
||||
// parameters use PostgreSQL convention, not MySQL
|
||||
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
|
||||
function SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs=0)
|
||||
{
|
||||
$offsetStr =($offset>=0) ? "$offset," : '';
|
||||
// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
|
||||
if ($nrows < 0) $nrows = '18446744073709551615';
|
||||
if ($nrows < 0) {
|
||||
$nrows = '18446744073709551615';
|
||||
}
|
||||
|
||||
if ($secs)
|
||||
$rs = $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
|
||||
else
|
||||
$rs = $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
|
||||
if ($secs) {
|
||||
$rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows", $inputarr);
|
||||
} else {
|
||||
$rs = $this->Execute($sql . " LIMIT $offsetStr$nrows", $inputarr);
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
|
||||
function SQLDate($fmt, $col=false)
|
||||
{
|
||||
if (!$col) {
|
||||
$col = $this->sysTimeStamp;
|
||||
}
|
||||
$s = 'DATE_FORMAT(' . $col . ",'";
|
||||
$concat = false;
|
||||
$len = strlen($fmt);
|
||||
for ($i=0; $i < $len; $i++) {
|
||||
$ch = $fmt[$i];
|
||||
switch($ch) {
|
||||
|
||||
default:
|
||||
if ($ch == '\\') {
|
||||
$i++;
|
||||
$ch = substr($fmt, $i, 1);
|
||||
}
|
||||
// FALL THROUGH
|
||||
case '-':
|
||||
case '/':
|
||||
$s .= $ch;
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
case 'y':
|
||||
$s .= '%Y';
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
$s .= '%b';
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
$s .= '%m';
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
case 'd':
|
||||
$s .= '%d';
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
case 'q':
|
||||
$s .= "'),Quarter($col)";
|
||||
|
||||
if ($len > $i+1) {
|
||||
$s .= ",DATE_FORMAT($col,'";
|
||||
} else {
|
||||
$s .= ",('";
|
||||
}
|
||||
$concat = true;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
$s .= '%H';
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
$s .= '%I';
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
$s .= '%i';
|
||||
break;
|
||||
|
||||
case 's':
|
||||
$s .= '%s';
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
case 'A':
|
||||
$s .= '%p';
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
$s .= '%w';
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
$s .= '%U';
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
$s .= '%W';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$s .= "')";
|
||||
if ($concat) {
|
||||
$s = "CONCAT($s)";
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Provided by Ned Andre to support sqlsrv library
|
||||
*/
|
||||
class ADODB_pdo_sqlsrv extends ADODB_pdo
|
||||
{
|
||||
|
||||
var $hasTop = 'top';
|
||||
var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
|
||||
var $sysTimeStamp = 'GetDate()';
|
||||
|
||||
function _init(ADODB_pdo $parentDriver)
|
||||
{
|
||||
$parentDriver->hasTransactions = true;
|
||||
$parentDriver->_bindInputArray = true;
|
||||
$parentDriver->hasInsertID = true;
|
||||
$parentDriver->fmtTimeStamp = "'Y-m-d H:i:s'";
|
||||
$parentDriver->fmtDate = "'Y-m-d'";
|
||||
}
|
||||
|
||||
function BeginTrans()
|
||||
{
|
||||
$returnval = parent::BeginTrans();
|
||||
return $returnval;
|
||||
}
|
||||
|
||||
function MetaColumns($table, $normalize = true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function MetaTables($ttype = false, $showSchema = false, $mask = false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0)
|
||||
{
|
||||
$ret = ADOConnection::SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
return ADOConnection::ServerInfo();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -145,19 +147,21 @@ class ADODB_postgres64 extends ADOConnection{
|
||||
// get the last id - never tested
|
||||
function pg_insert_id($tablename,$fieldname)
|
||||
{
|
||||
$result=pg_exec($this->_connectionID, "SELECT last_value FROM ${tablename}_${fieldname}_seq");
|
||||
$result=pg_query($this->_connectionID, 'SELECT last_value FROM '. $tablename .'_'. $fieldname .'_seq');
|
||||
if ($result) {
|
||||
$arr = @pg_fetch_row($result,0);
|
||||
pg_freeresult($result);
|
||||
pg_free_result($result);
|
||||
if (isset($arr[0])) return $arr[0];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Warning from http://www.php.net/manual/function.pg-getlastoid.php:
|
||||
Using a OID as a unique identifier is not generally wise.
|
||||
Unless you are very careful, you might end up with a tuple having
|
||||
a different OID if a database must be reloaded. */
|
||||
/**
|
||||
* Warning from http://www.php.net/manual/function.pg-getlastoid.php:
|
||||
* Using a OID as a unique identifier is not generally wise.
|
||||
* Unless you are very careful, you might end up with a tuple having
|
||||
* a different OID if a database must be reloaded.
|
||||
*/
|
||||
function _insertid($table,$column)
|
||||
{
|
||||
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
|
||||
@@ -166,21 +170,21 @@ a different OID if a database must be reloaded. */
|
||||
return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid);
|
||||
}
|
||||
|
||||
// I get this error with PHP before 4.0.6 - jlim
|
||||
// Warning: This compilation does not support pg_cmdtuples() in adodb-postgres.inc.php on line 44
|
||||
function _affectedrows()
|
||||
{
|
||||
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
|
||||
return pg_cmdtuples($this->_resultid);
|
||||
return pg_affected_rows($this->_resultid);
|
||||
}
|
||||
|
||||
|
||||
// returns true/false
|
||||
/**
|
||||
* @return true/false
|
||||
*/
|
||||
function BeginTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
$this->transCnt += 1;
|
||||
return @pg_Exec($this->_connectionID, "begin ".$this->_transmode);
|
||||
return pg_query($this->_connectionID, 'begin '.$this->_transmode);
|
||||
}
|
||||
|
||||
function RowLock($tables,$where,$col='1 as adodbignore')
|
||||
@@ -196,7 +200,7 @@ a different OID if a database must be reloaded. */
|
||||
if (!$ok) return $this->RollbackTrans();
|
||||
|
||||
$this->transCnt -= 1;
|
||||
return @pg_Exec($this->_connectionID, "commit");
|
||||
return pg_query($this->_connectionID, 'commit');
|
||||
}
|
||||
|
||||
// returns true/false
|
||||
@@ -204,7 +208,7 @@ a different OID if a database must be reloaded. */
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
$this->transCnt -= 1;
|
||||
return @pg_Exec($this->_connectionID, "rollback");
|
||||
return pg_query($this->_connectionID, 'rollback');
|
||||
}
|
||||
|
||||
function MetaTables($ttype=false,$showSchema=false,$mask=false)
|
||||
@@ -354,7 +358,7 @@ a different OID if a database must be reloaded. */
|
||||
*/
|
||||
function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
|
||||
{
|
||||
pg_exec ($this->_connectionID, "begin");
|
||||
pg_query($this->_connectionID, 'begin');
|
||||
|
||||
$fd = fopen($path,'r');
|
||||
$contents = fread($fd,filesize($path));
|
||||
@@ -366,7 +370,7 @@ a different OID if a database must be reloaded. */
|
||||
pg_lo_close($handle);
|
||||
|
||||
// $oid = pg_lo_import ($path);
|
||||
pg_exec($this->_connectionID, "commit");
|
||||
pg_query($this->_connectionID, 'commit');
|
||||
$rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype);
|
||||
$rez = !empty($rs);
|
||||
return $rez;
|
||||
@@ -382,9 +386,9 @@ a different OID if a database must be reloaded. */
|
||||
*/
|
||||
function BlobDelete( $blob )
|
||||
{
|
||||
pg_exec ($this->_connectionID, "begin");
|
||||
pg_query($this->_connectionID, 'begin');
|
||||
$result = @pg_lo_unlink($blob);
|
||||
pg_exec ($this->_connectionID, "commit");
|
||||
pg_query($this->_connectionID, 'commit');
|
||||
return( $result );
|
||||
}
|
||||
|
||||
@@ -413,16 +417,16 @@ a different OID if a database must be reloaded. */
|
||||
{
|
||||
if (!$this->GuessOID($blob)) return $blob;
|
||||
|
||||
if ($hastrans) @pg_exec($this->_connectionID,"begin");
|
||||
$fd = @pg_lo_open($this->_connectionID,$blob,"r");
|
||||
if ($hastrans) pg_query($this->_connectionID,'begin');
|
||||
$fd = @pg_lo_open($this->_connectionID,$blob,'r');
|
||||
if ($fd === false) {
|
||||
if ($hastrans) @pg_exec($this->_connectionID,"commit");
|
||||
if ($hastrans) pg_query($this->_connectionID,'commit');
|
||||
return $blob;
|
||||
}
|
||||
if (!$maxsize) $maxsize = $this->maxblobsize;
|
||||
$realblob = @pg_loread($fd,$maxsize);
|
||||
$realblob = @pg_lo_read($fd,$maxsize);
|
||||
@pg_loclose($fd);
|
||||
if ($hastrans) @pg_exec($this->_connectionID,"commit");
|
||||
if ($hastrans) pg_query($this->_connectionID,'commit');
|
||||
return $realblob;
|
||||
}
|
||||
|
||||
@@ -470,13 +474,28 @@ a different OID if a database must be reloaded. */
|
||||
#return "($date+interval'$dayFraction days')";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the SQL to retrieve MetaColumns data
|
||||
* @param string $table Table name
|
||||
* @param string $schema Schema name (can be blank)
|
||||
* @return string SQL statement to execute
|
||||
*/
|
||||
protected function _generateMetaColumnsSQL($table, $schema)
|
||||
{
|
||||
if ($schema) {
|
||||
return sprintf($this->metaColumnsSQL1, $table, $table, $schema);
|
||||
}
|
||||
else {
|
||||
return sprintf($this->metaColumnsSQL, $table, $table, $schema);
|
||||
}
|
||||
}
|
||||
|
||||
// for schema support, pass in the $table param "$schema.$tabname".
|
||||
// converts field names to lowercase, $upper is ignored
|
||||
// see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info
|
||||
function MetaColumns($table,$normalize=true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
global $ADODB_FETCH_MODE;
|
||||
|
||||
$schema = false;
|
||||
$false = false;
|
||||
@@ -488,8 +507,7 @@ a different OID if a database must be reloaded. */
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
|
||||
|
||||
if ($schema) $rs = $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
|
||||
else $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table,$table));
|
||||
$rs = $this->Execute($this->_generateMetaColumnsSQL($table, $schema));
|
||||
if (isset($savem)) $this->SetFetchMode($savem);
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
|
||||
@@ -721,7 +739,7 @@ a different OID if a database must be reloaded. */
|
||||
# PHP does not handle 'hex' properly ('x74657374' is returned as 't657374')
|
||||
# https://bugs.php.net/bug.php?id=59831 states this is in fact not a bug,
|
||||
# so we manually set bytea_output
|
||||
if (version_compare($info['version'], '9.0', '>=')) {
|
||||
if ( !empty($this->connection->noBlobs) && version_compare($info['version'], '9.0', '>=')) {
|
||||
$this->Execute('set bytea_output=escape');
|
||||
}
|
||||
|
||||
@@ -759,9 +777,6 @@ a different OID if a database must be reloaded. */
|
||||
|
||||
with plan = 1.51861286163 secs
|
||||
no plan = 1.26903700829 secs
|
||||
|
||||
|
||||
|
||||
*/
|
||||
$plan = 'P'.md5($sql);
|
||||
|
||||
@@ -779,7 +794,7 @@ a different OID if a database must be reloaded. */
|
||||
else $exsql = "EXECUTE $plan";
|
||||
|
||||
|
||||
$rez = @pg_exec($this->_connectionID,$exsql);
|
||||
$rez = @pg_execute($this->_connectionID,$exsql);
|
||||
if (!$rez) {
|
||||
# Perhaps plan does not exist? Prepare/compile plan.
|
||||
$params = '';
|
||||
@@ -803,19 +818,19 @@ a different OID if a database must be reloaded. */
|
||||
}
|
||||
$s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2);
|
||||
//adodb_pr($s);
|
||||
$rez = pg_exec($this->_connectionID,$s);
|
||||
$rez = pg_execute($this->_connectionID,$s);
|
||||
//echo $this->ErrorMsg();
|
||||
}
|
||||
if ($rez)
|
||||
$rez = pg_exec($this->_connectionID,$exsql);
|
||||
$rez = pg_execute($this->_connectionID,$exsql);
|
||||
} else {
|
||||
//adodb_backtrace();
|
||||
$rez = pg_exec($this->_connectionID,$sql);
|
||||
$rez = pg_query($this->_connectionID,$sql);
|
||||
}
|
||||
// check if no data returned, then no need to create real recordset
|
||||
if ($rez && pg_numfields($rez) <= 0) {
|
||||
if ($rez && pg_num_fields($rez) <= 0) {
|
||||
if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
|
||||
pg_freeresult($this->_resultid);
|
||||
pg_free_result($this->_resultid);
|
||||
}
|
||||
$this->_resultid = $rez;
|
||||
return true;
|
||||
@@ -864,7 +879,7 @@ a different OID if a database must be reloaded. */
|
||||
{
|
||||
if ($this->transCnt) $this->RollbackTrans();
|
||||
if ($this->_resultid) {
|
||||
@pg_freeresult($this->_resultid);
|
||||
@pg_free_result($this->_resultid);
|
||||
$this->_resultid = false;
|
||||
}
|
||||
@pg_close($this->_connectionID);
|
||||
@@ -919,12 +934,14 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
||||
$this->adodbFetchMode = $mode;
|
||||
|
||||
// Parent's constructor
|
||||
$this->ADORecordSet($queryID);
|
||||
parent::__construct($queryID);
|
||||
}
|
||||
|
||||
function GetRowAssoc($upper=true)
|
||||
function GetRowAssoc($upper = ADODB_ASSOC_CASE)
|
||||
{
|
||||
if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields;
|
||||
if ($this->fetchMode == PGSQL_ASSOC && $upper == ADODB_ASSOC_CASE_LOWER) {
|
||||
return $this->fields;
|
||||
}
|
||||
$row = ADORecordSet::GetRowAssoc($upper);
|
||||
return $row;
|
||||
}
|
||||
@@ -934,15 +951,15 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
||||
{
|
||||
global $ADODB_COUNTRECS;
|
||||
$qid = $this->_queryID;
|
||||
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1;
|
||||
$this->_numOfFields = @pg_numfields($qid);
|
||||
$this->_numOfRows = ($ADODB_COUNTRECS)? @pg_num_rows($qid):-1;
|
||||
$this->_numOfFields = @pg_num_fields($qid);
|
||||
|
||||
// cache types for blob decode check
|
||||
// apparently pg_fieldtype actually performs an sql query on the database to get the type.
|
||||
// apparently pg_field_type actually performs an sql query on the database to get the type.
|
||||
if (empty($this->connection->noBlobs))
|
||||
for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
|
||||
if (pg_fieldtype($qid,$i) == 'bytea') {
|
||||
$this->_blobArr[$i] = pg_fieldname($qid,$i);
|
||||
if (pg_field_type($qid,$i) == 'bytea') {
|
||||
$this->_blobArr[$i] = pg_field_name($qid,$i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,8 +984,8 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
||||
// offsets begin at 0
|
||||
|
||||
$o= new ADOFieldObject();
|
||||
$o->name = @pg_fieldname($this->_queryID,$off);
|
||||
$o->type = @pg_fieldtype($this->_queryID,$off);
|
||||
$o->name = @pg_field_name($this->_queryID,$off);
|
||||
$o->type = @pg_field_type($this->_queryID,$off);
|
||||
$o->max_length = @pg_fieldsize($this->_queryID,$off);
|
||||
return $o;
|
||||
}
|
||||
@@ -1032,7 +1049,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
|
||||
|
||||
function _close()
|
||||
{
|
||||
return @pg_freeresult($this->_queryID);
|
||||
return @pg_free_result($this->_queryID);
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -21,64 +23,82 @@ class ADODB_postgres7 extends ADODB_postgres64 {
|
||||
var $hasLimit = true; // set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
|
||||
var $ansiOuter = true;
|
||||
var $charSet = true; //set to true for Postgres 7 and above - PG client supports encodings
|
||||
// Richard 3/18/2012 - Modified SQL to return SERIAL type correctly AS old driver no longer return SERIAL as data type.
|
||||
var $metaColumnsSQL =
|
||||
"SELECT a.attname,
|
||||
CASE
|
||||
WHEN x.sequence_name != '' THEN 'SERIAL'
|
||||
ELSE t.typname
|
||||
END AS typname,
|
||||
a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum
|
||||
FROM pg_class c, pg_attribute a
|
||||
JOIN pg_type t ON a.atttypid = t.oid
|
||||
LEFT JOIN
|
||||
(SELECT c.relname as sequence_name,
|
||||
c1.relname as related_table,
|
||||
a.attname as related_column
|
||||
FROM pg_class c
|
||||
JOIN pg_depend d ON d.objid = c.oid
|
||||
LEFT JOIN pg_class c1 ON d.refobjid = c1.oid
|
||||
LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
|
||||
WHERE c.relkind = 'S' AND c1.relname = '%s') x
|
||||
ON x.related_column= a.attname
|
||||
WHERE c.relkind in ('r','v') AND
|
||||
(c.relname='%s' or c.relname = lower('%s')) AND
|
||||
a.attname not like '....%%' AND
|
||||
a.attnum > 0 AND
|
||||
a.attrelid = c.oid
|
||||
ORDER BY a.attnum";
|
||||
|
||||
// used when schema defined
|
||||
// Richard 3/18/2012 - Modified SQL to return SERIAL type correctly AS old driver no longer return SERIAL as data type.
|
||||
var $metaColumnsSQL = "
|
||||
SELECT
|
||||
a.attname,
|
||||
CASE
|
||||
WHEN x.sequence_name != ''
|
||||
THEN 'SERIAL'
|
||||
ELSE t.typname
|
||||
END AS typname,
|
||||
a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
|
||||
FROM
|
||||
pg_class c,
|
||||
pg_attribute a
|
||||
JOIN pg_type t ON a.atttypid = t.oid
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
c.relname as sequence_name,
|
||||
c1.relname as related_table,
|
||||
a.attname as related_column
|
||||
FROM pg_class c
|
||||
JOIN pg_depend d ON d.objid = c.oid
|
||||
LEFT JOIN pg_class c1 ON d.refobjid = c1.oid
|
||||
LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
|
||||
WHERE c.relkind = 'S' AND c1.relname = '%s'
|
||||
) x ON x.related_column= a.attname
|
||||
WHERE
|
||||
c.relkind in ('r','v')
|
||||
AND (c.relname='%s' or c.relname = lower('%s'))
|
||||
AND a.attname not like '....%%'
|
||||
AND a.attnum > 0
|
||||
AND a.attrelid = c.oid
|
||||
ORDER BY
|
||||
a.attnum";
|
||||
|
||||
// used when schema defined
|
||||
var $metaColumnsSQL1 = "
|
||||
SELECT a.attname,
|
||||
CASE
|
||||
WHEN x.sequence_name != '' THEN 'SERIAL'
|
||||
ELSE t.typname
|
||||
END AS typname,
|
||||
a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
|
||||
FROM pg_class c, pg_namespace n, pg_attribute a
|
||||
JOIN pg_type t ON a.atttypid = t.oid
|
||||
LEFT JOIN
|
||||
(SELECT c.relname as sequence_name,
|
||||
c1.relname as related_table,
|
||||
a.attname as related_column
|
||||
FROM pg_class c
|
||||
JOIN pg_depend d ON d.objid = c.oid
|
||||
LEFT JOIN pg_class c1 ON d.refobjid = c1.oid
|
||||
LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
|
||||
WHERE c.relkind = 'S' AND c1.relname = '%s') x
|
||||
ON x.related_column= a.attname
|
||||
WHERE c.relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
|
||||
AND c.relnamespace=n.oid and n.nspname='%s'
|
||||
AND a.attname not like '....%%' AND a.attnum > 0
|
||||
AND a.atttypid = t.oid AND a.attrelid = c.oid
|
||||
ORDER BY a.attnum";
|
||||
SELECT
|
||||
a.attname,
|
||||
CASE
|
||||
WHEN x.sequence_name != ''
|
||||
THEN 'SERIAL'
|
||||
ELSE t.typname
|
||||
END AS typname,
|
||||
a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
|
||||
FROM
|
||||
pg_class c,
|
||||
pg_namespace n,
|
||||
pg_attribute a
|
||||
JOIN pg_type t ON a.atttypid = t.oid
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
c.relname as sequence_name,
|
||||
c1.relname as related_table,
|
||||
a.attname as related_column
|
||||
FROM pg_class c
|
||||
JOIN pg_depend d ON d.objid = c.oid
|
||||
LEFT JOIN pg_class c1 ON d.refobjid = c1.oid
|
||||
LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum)
|
||||
WHERE c.relkind = 'S' AND c1.relname = '%s'
|
||||
) x ON x.related_column= a.attname
|
||||
WHERE
|
||||
c.relkind in ('r','v')
|
||||
AND (c.relname='%s' or c.relname = lower('%s'))
|
||||
AND c.relnamespace=n.oid and n.nspname='%s'
|
||||
AND a.attname not like '....%%'
|
||||
AND a.attnum > 0
|
||||
AND a.atttypid = t.oid
|
||||
AND a.attrelid = c.oid
|
||||
ORDER BY a.attnum";
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (ADODB_ASSOC_CASE !== 2) {
|
||||
if (ADODB_ASSOC_CASE !== ADODB_ASSOC_CASE_NATIVE) {
|
||||
$this->rsPrefix .= 'assoc_';
|
||||
}
|
||||
$this->_bindInputArray = PHP_VERSION >= 5.1;
|
||||
@@ -87,19 +107,20 @@ class ADODB_postgres7 extends ADODB_postgres64 {
|
||||
|
||||
// the following should be compat with postgresql 7.2,
|
||||
// which makes obsolete the LIMIT limit,offset syntax
|
||||
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
|
||||
{
|
||||
$offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : '';
|
||||
$limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : '';
|
||||
if ($secs2cache)
|
||||
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
|
||||
else
|
||||
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
|
||||
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
|
||||
{
|
||||
$offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : '';
|
||||
$limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : '';
|
||||
if ($secs2cache)
|
||||
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
|
||||
else
|
||||
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/*
|
||||
function Prepare($sql)
|
||||
}
|
||||
|
||||
/*
|
||||
function Prepare($sql)
|
||||
{
|
||||
$info = $this->ServerInfo();
|
||||
if ($info['version']>=7.3) {
|
||||
@@ -107,55 +128,72 @@ class ADODB_postgres7 extends ADODB_postgres64 {
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
I discovered that the MetaForeignKeys method no longer worked for Postgres 8.3.
|
||||
I went ahead and modified it to work for both 8.2 and 8.3.
|
||||
Please feel free to include this change in your next release of adodb.
|
||||
William Kolodny [William.Kolodny#gt-t.net]
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate the SQL to retrieve MetaColumns data
|
||||
* @param string $table Table name
|
||||
* @param string $schema Schema name (can be blank)
|
||||
* @return string SQL statement to execute
|
||||
*/
|
||||
protected function _generateMetaColumnsSQL($table, $schema)
|
||||
{
|
||||
if ($schema) {
|
||||
return sprintf($this->metaColumnsSQL1, $table, $table, $table, $schema);
|
||||
}
|
||||
else {
|
||||
return sprintf($this->metaColumnsSQL, $table, $table, $schema);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns assoc array where keys are tables, and values are foreign keys
|
||||
*/
|
||||
function MetaForeignKeys($table, $owner=false, $upper=false)
|
||||
{
|
||||
$sql="
|
||||
SELECT fum.ftblname AS lookup_table, split_part(fum.rf, ')'::text, 1) AS lookup_field,
|
||||
fum.ltable AS dep_table, split_part(fum.lf, ')'::text, 1) AS dep_field
|
||||
FROM (
|
||||
SELECT fee.ltable, fee.ftblname, fee.consrc, split_part(fee.consrc,'('::text, 2) AS lf,
|
||||
split_part(fee.consrc, '('::text, 3) AS rf
|
||||
FROM (
|
||||
SELECT foo.relname AS ltable, foo.ftblname,
|
||||
pg_get_constraintdef(foo.oid) AS consrc
|
||||
FROM (
|
||||
SELECT c.oid, c.conname AS name, t.relname, ft.relname AS ftblname
|
||||
FROM pg_constraint c
|
||||
JOIN pg_class t ON (t.oid = c.conrelid)
|
||||
JOIN pg_class ft ON (ft.oid = c.confrelid)
|
||||
JOIN pg_namespace nft ON (nft.oid = ft.relnamespace)
|
||||
LEFT JOIN pg_description ds ON (ds.objoid = c.oid)
|
||||
JOIN pg_namespace n ON (n.oid = t.relnamespace)
|
||||
WHERE c.contype = 'f'::\"char\"
|
||||
ORDER BY t.relname, n.nspname, c.conname, c.oid
|
||||
) foo
|
||||
) fee) fum
|
||||
WHERE fum.ltable='".strtolower($table)."'
|
||||
ORDER BY fum.ftblname, fum.ltable, split_part(fum.lf, ')'::text, 1)
|
||||
";
|
||||
$rs = $this->Execute($sql);
|
||||
# Regex isolates the 2 terms between parenthesis using subexpressions
|
||||
$regex = '^.*\((.*)\).*\((.*)\).*$';
|
||||
$sql="
|
||||
SELECT
|
||||
lookup_table,
|
||||
regexp_replace(consrc, '$regex', '\\2') AS lookup_field,
|
||||
dep_table,
|
||||
regexp_replace(consrc, '$regex', '\\1') AS dep_field
|
||||
FROM (
|
||||
SELECT
|
||||
pg_get_constraintdef(c.oid) AS consrc,
|
||||
t.relname AS dep_table,
|
||||
ft.relname AS lookup_table
|
||||
FROM pg_constraint c
|
||||
JOIN pg_class t ON (t.oid = c.conrelid)
|
||||
JOIN pg_class ft ON (ft.oid = c.confrelid)
|
||||
JOIN pg_namespace nft ON (nft.oid = ft.relnamespace)
|
||||
LEFT JOIN pg_description ds ON (ds.objoid = c.oid)
|
||||
JOIN pg_namespace n ON (n.oid = t.relnamespace)
|
||||
WHERE c.contype = 'f'::\"char\"
|
||||
ORDER BY t.relname, n.nspname, c.conname, c.oid
|
||||
) constraints
|
||||
WHERE
|
||||
dep_table='".strtolower($table)."'
|
||||
ORDER BY
|
||||
lookup_table,
|
||||
dep_table,
|
||||
dep_field";
|
||||
$rs = $this->Execute($sql);
|
||||
|
||||
if (!$rs || $rs->EOF) return false;
|
||||
if (!$rs || $rs->EOF) return false;
|
||||
|
||||
$a = array();
|
||||
while (!$rs->EOF) {
|
||||
if ($upper) {
|
||||
$a[strtoupper($rs->Fields('lookup_table'))][] = strtoupper(str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field')));
|
||||
} else {
|
||||
$a[$rs->Fields('lookup_table')][] = str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field'));
|
||||
}
|
||||
$rs->MoveNext();
|
||||
}
|
||||
$a = array();
|
||||
while (!$rs->EOF) {
|
||||
if ($upper) {
|
||||
$a[strtoupper($rs->Fields('lookup_table'))][] = strtoupper(str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field')));
|
||||
} else {
|
||||
$a[$rs->Fields('lookup_table')][] = str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field'));
|
||||
}
|
||||
$rs->MoveNext();
|
||||
}
|
||||
|
||||
return $a;
|
||||
return $a;
|
||||
|
||||
}
|
||||
|
||||
@@ -219,9 +257,9 @@ class ADODB_postgres7 extends ADODB_postgres64 {
|
||||
$rez = pg_query($this->_connectionID,$sql);
|
||||
}
|
||||
// check if no data returned, then no need to create real recordset
|
||||
if ($rez && pg_numfields($rez) <= 0) {
|
||||
if ($rez && pg_num_fields($rez) <= 0) {
|
||||
if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
|
||||
pg_freeresult($this->_resultid);
|
||||
pg_free_result($this->_resultid);
|
||||
}
|
||||
$this->_resultid = $rez;
|
||||
return true;
|
||||
@@ -229,7 +267,7 @@ class ADODB_postgres7 extends ADODB_postgres64 {
|
||||
return $rez;
|
||||
}
|
||||
|
||||
// this is a set of functions for managing client encoding - very important if the encodings
|
||||
// this is a set of functions for managing client encoding - very important if the encodings
|
||||
// of your database and your output target (i.e. HTML) don't match
|
||||
//for instance, you may have UNICODE database and server it on-site as WIN1251 etc.
|
||||
// GetCharSet - get the name of the character set the client is using now
|
||||
@@ -262,7 +300,7 @@ class ADODB_postgres7 extends ADODB_postgres64 {
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
class ADORecordSet_postgres7 extends ADORecordSet_postgres64{
|
||||
@@ -308,8 +346,9 @@ class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
|
||||
|
||||
function _fetch()
|
||||
{
|
||||
if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0)
|
||||
return false;
|
||||
if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
|
||||
|
||||
@@ -321,26 +360,6 @@ class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
|
||||
return (is_array($this->fields));
|
||||
}
|
||||
|
||||
// Create associative array
|
||||
function _updatefields()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
$this->fields = $arr;
|
||||
}
|
||||
|
||||
function MoveNext()
|
||||
{
|
||||
if (!$this->EOF) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -23,9 +25,9 @@ if (! defined("_ADODB_PROXY_LAYER")) {
|
||||
class ADORecordset_proxy extends ADORecordset_csv {
|
||||
var $databaseType = "proxy";
|
||||
|
||||
function ADORecordset_proxy($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordset($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
};
|
||||
} // define
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -31,10 +33,10 @@ class ADODB_SAPDB extends ADODB_odbc {
|
||||
var $hasInsertId = true;
|
||||
var $_bindInputArray = true;
|
||||
|
||||
function ADODB_SAPDB()
|
||||
function __construct()
|
||||
{
|
||||
//if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC;
|
||||
$this->ADODB_odbc();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function ServerInfo()
|
||||
@@ -46,7 +48,7 @@ class ADODB_SAPDB extends ADODB_odbc {
|
||||
return $info;
|
||||
}
|
||||
|
||||
function MetaPrimaryKeys($table)
|
||||
function MetaPrimaryKeys($table, $owner = false)
|
||||
{
|
||||
$table = $this->Quote(strtoupper($table));
|
||||
|
||||
@@ -92,7 +94,7 @@ class ADODB_SAPDB extends ADODB_odbc {
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
function MetaColumns ($table)
|
||||
function MetaColumns ($table, $normalize = true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
@@ -140,7 +142,7 @@ class ADODB_SAPDB extends ADODB_odbc {
|
||||
return $retarr;
|
||||
}
|
||||
|
||||
function MetaColumnNames($table)
|
||||
function MetaColumnNames($table, $numIndexes = false, $useattnum = false)
|
||||
{
|
||||
$table = $this->Quote(strtoupper($table));
|
||||
|
||||
@@ -174,9 +176,9 @@ class ADORecordSet_sapdb extends ADORecordSet_odbc {
|
||||
|
||||
var $databaseType = "sapdb";
|
||||
|
||||
function ADORecordSet_sapdb($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_odbc($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
@@ -56,11 +58,6 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){
|
||||
var $databaseType = "sqlanywhere";
|
||||
var $hasInsertID = true;
|
||||
|
||||
function ADODB_sqlanywhere()
|
||||
{
|
||||
$this->ADODB_odbc();
|
||||
}
|
||||
|
||||
function _insertid() {
|
||||
return $this->GetOne('select @@identity');
|
||||
}
|
||||
@@ -156,9 +153,9 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){
|
||||
|
||||
var $databaseType = "sqlanywhere";
|
||||
|
||||
function ADORecordSet_sqlanywhere($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_odbc($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -31,19 +33,10 @@ class ADODB_sqlite extends ADOConnection {
|
||||
var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')";
|
||||
var $fmtTimeStamp = "'Y-m-d H:i:s'";
|
||||
|
||||
function ADODB_sqlite()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
function __get($name)
|
||||
{
|
||||
switch($name) {
|
||||
case 'sysDate': return "'".date($this->fmtDate)."'";
|
||||
case 'sysTimeStamp' : return "'".date($this->sysTimeStamp)."'";
|
||||
}
|
||||
}*/
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
$arr['version'] = sqlite_libversion();
|
||||
@@ -54,69 +47,90 @@ class ADODB_sqlite extends ADOConnection {
|
||||
|
||||
function BeginTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
$ret = $this->Execute("BEGIN TRANSACTION");
|
||||
$this->transCnt += 1;
|
||||
return true;
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
$ret = $this->Execute("BEGIN TRANSACTION");
|
||||
$this->transCnt += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
function CommitTrans($ok=true)
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
if (!$ok) return $this->RollbackTrans();
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
if (!$ok) {
|
||||
return $this->RollbackTrans();
|
||||
}
|
||||
$ret = $this->Execute("COMMIT");
|
||||
if ($this->transCnt>0)$this->transCnt -= 1;
|
||||
if ($this->transCnt > 0) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
return !empty($ret);
|
||||
}
|
||||
|
||||
function RollbackTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
$ret = $this->Execute("ROLLBACK");
|
||||
if ($this->transCnt>0)$this->transCnt -= 1;
|
||||
if ($this->transCnt > 0) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
return !empty($ret);
|
||||
}
|
||||
|
||||
// mark newnham
|
||||
function MetaColumns($table, $normalize=true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
|
||||
$rs = $this->Execute("PRAGMA table_info('$table')");
|
||||
if (isset($savem)) $this->SetFetchMode($savem);
|
||||
if (!$rs) {
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
$arr = array();
|
||||
while ($r = $rs->FetchRow()) {
|
||||
$type = explode('(',$r['type']);
|
||||
$size = '';
|
||||
if (sizeof($type)==2)
|
||||
$size = trim($type[1],')');
|
||||
$fn = strtoupper($r['name']);
|
||||
$fld = new ADOFieldObject;
|
||||
$fld->name = $r['name'];
|
||||
$fld->type = $type[0];
|
||||
$fld->max_length = $size;
|
||||
$fld->not_null = $r['notnull'];
|
||||
$fld->default_value = $r['dflt_value'];
|
||||
$fld->scale = 0;
|
||||
if (isset($r['pk']) && $r['pk']) $fld->primary_key=1;
|
||||
if ($save == ADODB_FETCH_NUM) $arr[] = $fld;
|
||||
else $arr[strtoupper($fld->name)] = $fld;
|
||||
}
|
||||
$rs->Close();
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $arr;
|
||||
global $ADODB_FETCH_MODE;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||
if ($this->fetchMode !== false) {
|
||||
$savem = $this->SetFetchMode(false);
|
||||
}
|
||||
$rs = $this->Execute("PRAGMA table_info('$table')");
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
if (!$rs) {
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
$arr = array();
|
||||
while ($r = $rs->FetchRow()) {
|
||||
$type = explode('(',$r['type']);
|
||||
$size = '';
|
||||
if (sizeof($type)==2) {
|
||||
$size = trim($type[1],')');
|
||||
}
|
||||
$fn = strtoupper($r['name']);
|
||||
$fld = new ADOFieldObject;
|
||||
$fld->name = $r['name'];
|
||||
$fld->type = $type[0];
|
||||
$fld->max_length = $size;
|
||||
$fld->not_null = $r['notnull'];
|
||||
$fld->default_value = $r['dflt_value'];
|
||||
$fld->scale = 0;
|
||||
if (isset($r['pk']) && $r['pk']) {
|
||||
$fld->primary_key=1;
|
||||
}
|
||||
if ($save == ADODB_FETCH_NUM) {
|
||||
$arr[] = $fld;
|
||||
} else {
|
||||
$arr[strtoupper($fld->name)] = $fld;
|
||||
}
|
||||
}
|
||||
$rs->Close();
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function _init($parentDriver)
|
||||
{
|
||||
|
||||
$parentDriver->hasTransactions = false;
|
||||
$parentDriver->hasInsertID = true;
|
||||
}
|
||||
@@ -128,12 +142,14 @@ class ADODB_sqlite extends ADOConnection {
|
||||
|
||||
function _affectedrows()
|
||||
{
|
||||
return sqlite_changes($this->_connectionID);
|
||||
}
|
||||
return sqlite_changes($this->_connectionID);
|
||||
}
|
||||
|
||||
function ErrorMsg()
|
||||
{
|
||||
if ($this->_logsql) return $this->_errorMsg;
|
||||
if ($this->_logsql) {
|
||||
return $this->_errorMsg;
|
||||
}
|
||||
return ($this->_errorNo) ? sqlite_error_string($this->_errorNo) : '';
|
||||
}
|
||||
|
||||
@@ -159,11 +175,17 @@ class ADODB_sqlite extends ADOConnection {
|
||||
// returns true or false
|
||||
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
if (!function_exists('sqlite_open')) return null;
|
||||
if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
|
||||
if (!function_exists('sqlite_open')) {
|
||||
return null;
|
||||
}
|
||||
if (empty($argHostname) && $argDatabasename) {
|
||||
$argHostname = $argDatabasename;
|
||||
}
|
||||
|
||||
$this->_connectionID = sqlite_open($argHostname);
|
||||
if ($this->_connectionID === false) return false;
|
||||
if ($this->_connectionID === false) {
|
||||
return false;
|
||||
}
|
||||
$this->_createFunctions();
|
||||
return true;
|
||||
}
|
||||
@@ -171,11 +193,17 @@ class ADODB_sqlite extends ADOConnection {
|
||||
// returns true or false
|
||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
if (!function_exists('sqlite_open')) return null;
|
||||
if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
|
||||
if (!function_exists('sqlite_open')) {
|
||||
return null;
|
||||
}
|
||||
if (empty($argHostname) && $argDatabasename) {
|
||||
$argHostname = $argDatabasename;
|
||||
}
|
||||
|
||||
$this->_connectionID = sqlite_popen($argHostname);
|
||||
if ($this->_connectionID === false) return false;
|
||||
if ($this->_connectionID === false) {
|
||||
return false;
|
||||
}
|
||||
$this->_createFunctions();
|
||||
return true;
|
||||
}
|
||||
@@ -187,6 +215,11 @@ class ADODB_sqlite extends ADOConnection {
|
||||
if (!$rez) {
|
||||
$this->_errorNo = sqlite_last_error($this->_connectionID);
|
||||
}
|
||||
// If no data was returned, we don't need to create a real recordset
|
||||
// Note: this code is untested, as I don't have a sqlite2 setup available
|
||||
elseif (sqlite_num_fields($rez) == 0) {
|
||||
$rez = true;
|
||||
}
|
||||
|
||||
return $rez;
|
||||
}
|
||||
@@ -195,10 +228,11 @@ class ADODB_sqlite extends ADOConnection {
|
||||
{
|
||||
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
|
||||
$limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : '');
|
||||
if ($secs2cache)
|
||||
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
|
||||
else
|
||||
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
|
||||
if ($secs2cache) {
|
||||
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
|
||||
} else {
|
||||
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
@@ -224,7 +258,9 @@ class ADODB_sqlite extends ADOConnection {
|
||||
$start -= 1;
|
||||
$num = '0';
|
||||
$ok = $this->Execute("insert into $seq values($start)");
|
||||
if (!$ok) return false;
|
||||
if (!$ok) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->Execute("update $seq set id=id+1 where id=$num");
|
||||
|
||||
@@ -242,17 +278,23 @@ class ADODB_sqlite extends ADOConnection {
|
||||
|
||||
function CreateSequence($seqname='adodbseq',$start=1)
|
||||
{
|
||||
if (empty($this->_genSeqSQL)) return false;
|
||||
if (empty($this->_genSeqSQL)) {
|
||||
return false;
|
||||
}
|
||||
$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
|
||||
if (!$ok) return false;
|
||||
if (!$ok) {
|
||||
return false;
|
||||
}
|
||||
$start -= 1;
|
||||
return $this->Execute("insert into $seqname values($start)");
|
||||
}
|
||||
|
||||
var $_dropSeqSQL = 'drop table %s';
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
if (empty($this->_dropSeqSQL)) return false;
|
||||
if (empty($this->_dropSeqSQL)) {
|
||||
return false;
|
||||
}
|
||||
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
|
||||
}
|
||||
|
||||
@@ -262,56 +304,59 @@ class ADODB_sqlite extends ADOConnection {
|
||||
return @sqlite_close($this->_connectionID);
|
||||
}
|
||||
|
||||
function MetaIndexes($table, $primary = FALSE, $owner=false, $owner = false)
|
||||
function MetaIndexes($table, $primary = FALSE, $owner = false)
|
||||
{
|
||||
$false = false;
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
global $ADODB_FETCH_MODE;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
$SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='%s'", strtolower($table));
|
||||
$rs = $this->Execute($SQL);
|
||||
if (!is_object($rs)) {
|
||||
if (isset($savem))
|
||||
$rs = $this->Execute($SQL);
|
||||
if (!is_object($rs)) {
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
return $false;
|
||||
}
|
||||
|
||||
$indexes = array ();
|
||||
while ($row = $rs->FetchRow()) {
|
||||
if ($primary && preg_match("/primary/i",$row[1]) == 0) continue;
|
||||
if (!isset($indexes[$row[0]])) {
|
||||
|
||||
$indexes[$row[0]] = array(
|
||||
'unique' => preg_match("/unique/i",$row[1]),
|
||||
'columns' => array());
|
||||
if ($primary && preg_match("/primary/i",$row[1]) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($indexes[$row[0]])) {
|
||||
$indexes[$row[0]] = array(
|
||||
'unique' => preg_match("/unique/i",$row[1]),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* There must be a more elegant way of doing this,
|
||||
* the index elements appear in the SQL statement
|
||||
* in cols[1] between parentheses
|
||||
* e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse)
|
||||
*/
|
||||
* There must be a more elegant way of doing this,
|
||||
* the index elements appear in the SQL statement
|
||||
* in cols[1] between parentheses
|
||||
* e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse)
|
||||
*/
|
||||
$cols = explode("(",$row[1]);
|
||||
$cols = explode(")",$cols[1]);
|
||||
array_pop($cols);
|
||||
$indexes[$row[0]]['columns'] = $cols;
|
||||
}
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
$this->SetFetchMode($savem);
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
}
|
||||
return $indexes;
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
class ADORecordset_sqlite extends ADORecordSet {
|
||||
@@ -319,7 +364,7 @@ class ADORecordset_sqlite extends ADORecordSet {
|
||||
var $databaseType = "sqlite";
|
||||
var $bind = false;
|
||||
|
||||
function ADORecordset_sqlite($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
|
||||
if ($mode === false) {
|
||||
@@ -327,9 +372,15 @@ class ADORecordset_sqlite extends ADORecordSet {
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
switch($mode) {
|
||||
case ADODB_FETCH_NUM: $this->fetchMode = SQLITE_NUM; break;
|
||||
case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break;
|
||||
default: $this->fetchMode = SQLITE_BOTH; break;
|
||||
case ADODB_FETCH_NUM:
|
||||
$this->fetchMode = SQLITE_NUM;
|
||||
break;
|
||||
case ADODB_FETCH_ASSOC:
|
||||
$this->fetchMode = SQLITE_ASSOC;
|
||||
break;
|
||||
default:
|
||||
$this->fetchMode = SQLITE_BOTH;
|
||||
break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
|
||||
@@ -360,15 +411,17 @@ class ADORecordset_sqlite extends ADORecordSet {
|
||||
return $fld;
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
{
|
||||
function _initrs()
|
||||
{
|
||||
$this->_numOfRows = @sqlite_num_rows($this->_queryID);
|
||||
$this->_numOfFields = @sqlite_num_fields($this->_queryID);
|
||||
}
|
||||
}
|
||||
|
||||
function Fields($colname)
|
||||
{
|
||||
if ($this->fetchMode != SQLITE_NUM) return $this->fields[$colname];
|
||||
if ($this->fetchMode != SQLITE_NUM) {
|
||||
return $this->fields[$colname];
|
||||
}
|
||||
if (!$this->bind) {
|
||||
$this->bind = array();
|
||||
for ($i=0; $i < $this->_numOfFields; $i++) {
|
||||
@@ -377,13 +430,13 @@ class ADORecordset_sqlite extends ADORecordSet {
|
||||
}
|
||||
}
|
||||
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
}
|
||||
|
||||
function _seek($row)
|
||||
{
|
||||
return sqlite_seek($this->_queryID, $row);
|
||||
}
|
||||
function _seek($row)
|
||||
{
|
||||
return sqlite_seek($this->_queryID, $row);
|
||||
}
|
||||
|
||||
function _fetch($ignore_fields=false)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -18,9 +20,7 @@ V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserv
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
// class ADODB_sqlite extends ADOConnection { **change
|
||||
class ADODB_sqlite3 extends ADOConnection {
|
||||
//var $databaseType = "sqlite"; **change
|
||||
var $databaseType = "sqlite3";
|
||||
var $replaceQuote = "''"; // string to use to replace quotes
|
||||
var $concat_operator='||';
|
||||
@@ -33,114 +33,123 @@ class ADODB_sqlite3 extends ADOConnection {
|
||||
var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')";
|
||||
var $fmtTimeStamp = "'Y-m-d H:i:s'";
|
||||
|
||||
//function ADODB_sqlite3() **change
|
||||
function ADODB_sqlite3()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
function __get($name)
|
||||
{
|
||||
switch($name) {
|
||||
case 'sysDate': return "'".date($this->fmtDate)."'";
|
||||
case 'sysTimeStamp' : return "'".date($this->sysTimeStamp)."'";
|
||||
}
|
||||
}*/
|
||||
|
||||
function ServerInfo()
|
||||
{
|
||||
$arr['version'] = $this->_connectionID->version(); //**tochange
|
||||
$arr['description'] = 'SQLite 3'; //**tochange
|
||||
//$arr['encoding'] = sqlite_libencoding();//**tochange
|
||||
$version = SQLite3::version();
|
||||
$arr['version'] = $version['versionString'];
|
||||
$arr['description'] = 'SQLite 3';
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function BeginTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
$ret = $this->Execute("BEGIN TRANSACTION");
|
||||
$this->transCnt += 1;
|
||||
return true;
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
$ret = $this->Execute("BEGIN TRANSACTION");
|
||||
$this->transCnt += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
function CommitTrans($ok=true)
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
if (!$ok) return $this->RollbackTrans();
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
if (!$ok) {
|
||||
return $this->RollbackTrans();
|
||||
}
|
||||
$ret = $this->Execute("COMMIT");
|
||||
if ($this->transCnt>0)$this->transCnt -= 1;
|
||||
if ($this->transCnt > 0) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
return !empty($ret);
|
||||
}
|
||||
|
||||
function RollbackTrans()
|
||||
{
|
||||
if ($this->transOff) return true;
|
||||
if ($this->transOff) {
|
||||
return true;
|
||||
}
|
||||
$ret = $this->Execute("ROLLBACK");
|
||||
if ($this->transCnt>0)$this->transCnt -= 1;
|
||||
if ($this->transCnt > 0) {
|
||||
$this->transCnt -= 1;
|
||||
}
|
||||
return !empty($ret);
|
||||
}
|
||||
|
||||
// mark newnham
|
||||
function MetaColumns($table, $normalize=true)
|
||||
{
|
||||
global $ADODB_FETCH_MODE;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
|
||||
$rs = $this->Execute("PRAGMA table_info('$table')");
|
||||
if (isset($savem)) $this->SetFetchMode($savem);
|
||||
if (!$rs) {
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
$arr = array();
|
||||
while ($r = $rs->FetchRow()) {
|
||||
|
||||
$type = explode('(',$r['type']);
|
||||
$size = '';
|
||||
if (sizeof($type)==2)
|
||||
$size = trim($type[1],')');
|
||||
$fn = strtoupper($r['name']);
|
||||
$fld = new ADOFieldObject;
|
||||
$fld->name = $r['name'];
|
||||
$fld->type = $type[0];
|
||||
$fld->max_length = $size;
|
||||
$fld->not_null = $r['notnull'];
|
||||
$fld->default_value = $r['dflt_value'];
|
||||
$fld->scale = 0;
|
||||
if (isset($r['pk']) && $r['pk']) $fld->primary_key=1;
|
||||
if ($save == ADODB_FETCH_NUM) $arr[] = $fld;
|
||||
else $arr[strtoupper($fld->name)] = $fld;
|
||||
}
|
||||
$rs->Close();
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $arr;
|
||||
global $ADODB_FETCH_MODE;
|
||||
$false = false;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||
if ($this->fetchMode !== false) {
|
||||
$savem = $this->SetFetchMode(false);
|
||||
}
|
||||
$rs = $this->Execute("PRAGMA table_info('$table')");
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
if (!$rs) {
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
$arr = array();
|
||||
while ($r = $rs->FetchRow()) {
|
||||
$type = explode('(',$r['type']);
|
||||
$size = '';
|
||||
if (sizeof($type)==2) {
|
||||
$size = trim($type[1],')');
|
||||
}
|
||||
$fn = strtoupper($r['name']);
|
||||
$fld = new ADOFieldObject;
|
||||
$fld->name = $r['name'];
|
||||
$fld->type = $type[0];
|
||||
$fld->max_length = $size;
|
||||
$fld->not_null = $r['notnull'];
|
||||
$fld->default_value = $r['dflt_value'];
|
||||
$fld->scale = 0;
|
||||
if (isset($r['pk']) && $r['pk']) {
|
||||
$fld->primary_key=1;
|
||||
}
|
||||
if ($save == ADODB_FETCH_NUM) {
|
||||
$arr[] = $fld;
|
||||
} else {
|
||||
$arr[strtoupper($fld->name)] = $fld;
|
||||
}
|
||||
}
|
||||
$rs->Close();
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function _init($parentDriver)
|
||||
{
|
||||
|
||||
$parentDriver->hasTransactions = false;
|
||||
$parentDriver->hasInsertID = true;
|
||||
}
|
||||
|
||||
function _insertid()
|
||||
{
|
||||
//return sqlite_last_insert_rowid($this->_connectionID)->; //**change
|
||||
return $this->_connectionID->lastInsertRowID();
|
||||
}
|
||||
|
||||
function _affectedrows()
|
||||
{
|
||||
return $this->_connectionID->changes();
|
||||
//return sqlite3_changes($this->_connectionID); //**tochange
|
||||
}
|
||||
}
|
||||
|
||||
function ErrorMsg()
|
||||
{
|
||||
if ($this->_logsql) return $this->_errorMsg;
|
||||
|
||||
if ($this->_logsql) {
|
||||
return $this->_errorMsg;
|
||||
}
|
||||
return ($this->_errorNo) ? $this->ErrorNo() : ''; //**tochange?
|
||||
}
|
||||
|
||||
@@ -158,53 +167,41 @@ class ADODB_sqlite3 extends ADOConnection {
|
||||
|
||||
function _createFunctions()
|
||||
{
|
||||
//@sqlite3_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1); *change
|
||||
$this->_connectionID->createFunction('adodb_date', 'adodb_date', 1);
|
||||
|
||||
//@sqlite3_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2);**change
|
||||
$this->_connectionID->createFunction('adodb_date2', 'adodb_date2', 2);
|
||||
}
|
||||
|
||||
|
||||
// returns true or false
|
||||
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) //**tochange: all the function need to be changed, just hacks for the moment
|
||||
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
|
||||
$this->_connectionID = new SQLite3($argDatabasename);
|
||||
if (empty($argHostname) && $argDatabasename) {
|
||||
$argHostname = $argDatabasename;
|
||||
}
|
||||
$this->_connectionID = new SQLite3($argHostname);
|
||||
$this->_createFunctions();
|
||||
|
||||
return true; // hack
|
||||
/*
|
||||
if (!function_exists('sqlite_open')) return null;
|
||||
if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
|
||||
|
||||
$this->_connectionID = sqlite_open($argHostname);
|
||||
if ($this->_connectionID === false) return false;
|
||||
$this->_createFunctions();
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) //**tochange
|
||||
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
|
||||
{
|
||||
if (!function_exists('sqlite_open')) return null;
|
||||
if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
|
||||
|
||||
$this->_connectionID = sqlite_popen($argHostname);
|
||||
if ($this->_connectionID === false) return false;
|
||||
$this->_createFunctions();
|
||||
return true;
|
||||
// There's no permanent connect in SQLite3
|
||||
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
|
||||
}
|
||||
|
||||
// returns query ID if successful, otherwise false
|
||||
function _query($sql,$inputarr=false)
|
||||
{
|
||||
//$rez = sqlite_query($sql,$this->_connectionID);//**change
|
||||
$rez = $this->_connectionID->query($sql);
|
||||
if (!$rez) {
|
||||
//$this->_errorNo = sqlite3_last_error($this->_connectionID);**change
|
||||
$this->_connectionID->lastErrorCode();
|
||||
if ($rez === false) {
|
||||
$this->_errorNo = $this->_connectionID->lastErrorCode();
|
||||
}
|
||||
// If no data was returned, we don't need to create a real recordset
|
||||
elseif ($rez->numColumns() == 0) {
|
||||
$rez->finalize();
|
||||
$rez = true;
|
||||
}
|
||||
|
||||
return $rez;
|
||||
@@ -214,10 +211,11 @@ class ADODB_sqlite3 extends ADOConnection {
|
||||
{
|
||||
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
|
||||
$limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : '');
|
||||
if ($secs2cache)
|
||||
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
|
||||
else
|
||||
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
|
||||
if ($secs2cache) {
|
||||
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
|
||||
} else {
|
||||
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
@@ -243,7 +241,9 @@ class ADODB_sqlite3 extends ADOConnection {
|
||||
$start -= 1;
|
||||
$num = '0';
|
||||
$ok = $this->Execute("insert into $seq values($start)");
|
||||
if (!$ok) return false;
|
||||
if (!$ok) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->Execute("update $seq set id=id+1 where id=$num");
|
||||
|
||||
@@ -261,88 +261,93 @@ class ADODB_sqlite3 extends ADOConnection {
|
||||
|
||||
function CreateSequence($seqname='adodbseq',$start=1)
|
||||
{
|
||||
if (empty($this->_genSeqSQL)) return false;
|
||||
if (empty($this->_genSeqSQL)) {
|
||||
return false;
|
||||
}
|
||||
$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
|
||||
if (!$ok) return false;
|
||||
if (!$ok) {
|
||||
return false;
|
||||
}
|
||||
$start -= 1;
|
||||
return $this->Execute("insert into $seqname values($start)");
|
||||
}
|
||||
|
||||
var $_dropSeqSQL = 'drop table %s';
|
||||
function DropSequence($seqname)
|
||||
function DropSequence($seqname = 'adodbseq')
|
||||
{
|
||||
if (empty($this->_dropSeqSQL)) return false;
|
||||
if (empty($this->_dropSeqSQL)) {
|
||||
return false;
|
||||
}
|
||||
return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function _close()
|
||||
{
|
||||
//return @sqlite3_close($this->_connectionID);**change
|
||||
return $this->_connectionID->close();
|
||||
}
|
||||
|
||||
function MetaIndexes($table, $primary = FALSE, $owner=false, $owner = false)
|
||||
function MetaIndexes($table, $primary = FALSE, $owner = false)
|
||||
{
|
||||
$false = false;
|
||||
// save old fetch mode
|
||||
global $ADODB_FETCH_MODE;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
global $ADODB_FETCH_MODE;
|
||||
$save = $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
|
||||
if ($this->fetchMode !== FALSE) {
|
||||
$savem = $this->SetFetchMode(FALSE);
|
||||
}
|
||||
$SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='%s'", strtolower($table));
|
||||
$rs = $this->Execute($SQL);
|
||||
if (!is_object($rs)) {
|
||||
if (isset($savem))
|
||||
$rs = $this->Execute($SQL);
|
||||
if (!is_object($rs)) {
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
}
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
return $false;
|
||||
}
|
||||
return $false;
|
||||
}
|
||||
|
||||
$indexes = array ();
|
||||
while ($row = $rs->FetchRow()) {
|
||||
if ($primary && preg_match("/primary/i",$row[1]) == 0) continue;
|
||||
if (!isset($indexes[$row[0]])) {
|
||||
|
||||
$indexes[$row[0]] = array(
|
||||
'unique' => preg_match("/unique/i",$row[1]),
|
||||
'columns' => array());
|
||||
if ($primary && preg_match("/primary/i",$row[1]) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($indexes[$row[0]])) {
|
||||
$indexes[$row[0]] = array(
|
||||
'unique' => preg_match("/unique/i",$row[1]),
|
||||
'columns' => array()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* There must be a more elegant way of doing this,
|
||||
* the index elements appear in the SQL statement
|
||||
* in cols[1] between parentheses
|
||||
* e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse)
|
||||
*/
|
||||
* There must be a more elegant way of doing this,
|
||||
* the index elements appear in the SQL statement
|
||||
* in cols[1] between parentheses
|
||||
* e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse)
|
||||
*/
|
||||
$cols = explode("(",$row[1]);
|
||||
$cols = explode(")",$cols[1]);
|
||||
array_pop($cols);
|
||||
$indexes[$row[0]]['columns'] = $cols;
|
||||
}
|
||||
if (isset($savem)) {
|
||||
$this->SetFetchMode($savem);
|
||||
$this->SetFetchMode($savem);
|
||||
$ADODB_FETCH_MODE = $save;
|
||||
}
|
||||
return $indexes;
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
//class ADORecordset_sqlite extends ADORecordSet {**change
|
||||
class ADORecordset_sqlite3 extends ADORecordSet {
|
||||
|
||||
//var $databaseType = "sqlite";**change
|
||||
var $databaseType = "sqlite3";
|
||||
var $bind = false;
|
||||
|
||||
//function ADORecordset_sqlite($queryID,$mode=false)**change
|
||||
function ADORecordset_sqlite3($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
|
||||
if ($mode === false) {
|
||||
@@ -350,12 +355,15 @@ class ADORecordset_sqlite3 extends ADORecordSet {
|
||||
$mode = $ADODB_FETCH_MODE;
|
||||
}
|
||||
switch($mode) {
|
||||
//case ADODB_FETCH_NUM: $this->fetchMode = SQLITE_NUM; break;**change
|
||||
case ADODB_FETCH_NUM: $this->fetchMode = SQLITE3_NUM; break;
|
||||
//case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break;**change
|
||||
case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE3_ASSOC; break;
|
||||
//default: $this->fetchMode = SQLITE_BOTH; break;**change
|
||||
default: $this->fetchMode = SQLITE3_BOTH; break;
|
||||
case ADODB_FETCH_NUM:
|
||||
$this->fetchMode = SQLITE3_NUM;
|
||||
break;
|
||||
case ADODB_FETCH_ASSOC:
|
||||
$this->fetchMode = SQLITE3_ASSOC;
|
||||
break;
|
||||
default:
|
||||
$this->fetchMode = SQLITE3_BOTH;
|
||||
break;
|
||||
}
|
||||
$this->adodbFetchMode = $mode;
|
||||
|
||||
@@ -380,26 +388,23 @@ class ADORecordset_sqlite3 extends ADORecordSet {
|
||||
function FetchField($fieldOffset = -1)
|
||||
{
|
||||
$fld = new ADOFieldObject;
|
||||
//$fld->name = sqlite3_field_name($this->_queryID, $fieldOffset);**change
|
||||
$fld->name->columnName($this->_queryID, $fieldOffset);
|
||||
$fld->name = $this->_queryID->columnName($fieldOffset);
|
||||
$fld->type = 'VARCHAR';
|
||||
$fld->max_length = -1;
|
||||
return $fld;
|
||||
}
|
||||
|
||||
function _initrs()
|
||||
{
|
||||
//$this->_numOfRows = @sqlite_num_rows($this->_queryID); **tochange but sqlite3 doesn't implement this!
|
||||
$this->_numOfRows = 1;
|
||||
//$this->_numOfFields = @sqlite3_num_fields($this->_queryID);**change
|
||||
function _initrs()
|
||||
{
|
||||
$this->_numOfFields = $this->_queryID->numColumns();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function Fields($colname)
|
||||
{
|
||||
//if ($this->fetchMode != SQLITE_NUM) return $this->fields[$colname];**change
|
||||
if ($this->fetchMode != SQLITE3_NUM) return $this->fields[$colname];
|
||||
if ($this->fetchMode != SQLITE3_NUM) {
|
||||
return $this->fields[$colname];
|
||||
}
|
||||
if (!$this->bind) {
|
||||
$this->bind = array();
|
||||
for ($i=0; $i < $this->_numOfFields; $i++) {
|
||||
@@ -408,17 +413,20 @@ class ADORecordset_sqlite3 extends ADORecordSet {
|
||||
}
|
||||
}
|
||||
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
return $this->fields[$this->bind[strtoupper($colname)]];
|
||||
}
|
||||
|
||||
function _seek($row)
|
||||
{
|
||||
return sqlite3_seek($this->_queryID, $row);//**tochange but sqlite3 seems not to implement seek!
|
||||
}
|
||||
function _seek($row)
|
||||
{
|
||||
// sqlite3 does not implement seek
|
||||
if ($this->debug) {
|
||||
ADOConnection::outp("SQLite3 does not implement seek");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function _fetch($ignore_fields=false)
|
||||
{
|
||||
//$this->fields = @sqlite3_fetch_array($this->_queryID,$this->fetchMode);**change
|
||||
$this->fields = $this->_queryID->fetchArray($this->fetchMode);
|
||||
return !empty($this->fields);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -23,11 +25,6 @@ include_once(ADODB_DIR.'/drivers/adodb-sqlite.inc.php');
|
||||
|
||||
class ADODB_sqlitepo extends ADODB_sqlite {
|
||||
var $databaseType = 'sqlitepo';
|
||||
|
||||
function ADODB_sqlitepo()
|
||||
{
|
||||
$this->ADODB_sqlite();
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
@@ -38,9 +35,9 @@ class ADORecordset_sqlitepo extends ADORecordset_sqlite {
|
||||
|
||||
var $databaseType = 'sqlitepo';
|
||||
|
||||
function ADORecordset_sqlitepo($queryID,$mode=false)
|
||||
function __construct($queryID,$mode=false)
|
||||
{
|
||||
$this->ADORecordset_sqlite($queryID,$mode);
|
||||
parent::__construct($queryID,$mode);
|
||||
}
|
||||
|
||||
// Modified to strip table names from returned fields
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim. All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -42,7 +44,7 @@ class ADODB_sybase extends ADOConnection {
|
||||
|
||||
var $port;
|
||||
|
||||
function ADODB_sybase()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -278,7 +280,7 @@ class ADODB_sybase extends ADOConnection {
|
||||
# Added 2003-10-07 by Chris Phillipson
|
||||
# Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8
|
||||
# to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version
|
||||
function MetaPrimaryKeys($table)
|
||||
function MetaPrimaryKeys($table, $owner = false)
|
||||
{
|
||||
$sql = "SELECT c.column_name " .
|
||||
"FROM syscolumn c, systable t " .
|
||||
@@ -308,7 +310,7 @@ class ADORecordset_sybase extends ADORecordSet {
|
||||
// _mths works only in non-localised system
|
||||
var $_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
|
||||
|
||||
function ADORecordset_sybase($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
if ($mode === false) {
|
||||
global $ADODB_FETCH_MODE;
|
||||
@@ -316,7 +318,7 @@ class ADORecordset_sybase extends ADORecordSet {
|
||||
}
|
||||
if (!$mode) $this->fetchMode = ADODB_FETCH_ASSOC;
|
||||
else $this->fetchMode = $mode;
|
||||
$this->ADORecordSet($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
/* Returns: an object containing field information.
|
||||
@@ -356,7 +358,7 @@ class ADORecordset_sybase extends ADORecordSet {
|
||||
$this->fields = @sybase_fetch_assoc($this->_queryID);
|
||||
|
||||
if (is_array($this->fields)) {
|
||||
$this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
|
||||
$this->fields = $this->GetRowAssoc();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -389,9 +391,9 @@ class ADORecordset_sybase extends ADORecordSet {
|
||||
}
|
||||
|
||||
class ADORecordSet_array_sybase extends ADORecordSet_array {
|
||||
function ADORecordSet_array_sybase($id=-1)
|
||||
function __construct($id=-1)
|
||||
{
|
||||
$this->ADORecordSet_array($id);
|
||||
parent::__construct($id);
|
||||
}
|
||||
|
||||
// sybase/mssql uses a default date like Dec 30 2000 12:00AM
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -20,7 +22,7 @@ class ADODB_sybase_ase extends ADODB_sybase {
|
||||
var $metaColumnsSQL = "SELECT syscolumns.name AS field_name, systypes.name AS type, systypes.length AS width FROM sysobjects, syscolumns, systypes WHERE sysobjects.name='%s' AND syscolumns.id = sysobjects.id AND systypes.type=syscolumns.type";
|
||||
var $metaDatabasesSQL ="SELECT a.name FROM master.dbo.sysdatabases a, master.dbo.syslogins b WHERE a.suid = b.suid and a.name like '%' and a.name != 'tempdb' and a.status3 != 256 order by 1";
|
||||
|
||||
function ADODB_sybase_ase()
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -110,9 +112,9 @@ class ADODB_sybase_ase extends ADODB_sybase {
|
||||
|
||||
class adorecordset_sybase_ase extends ADORecordset_sybase {
|
||||
var $databaseType = "sybase_ase";
|
||||
function ADORecordset_sybase_ase($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
$this->ADORecordSet_sybase($id,$mode);
|
||||
parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
/*
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
Set tabs to 4.
|
||||
*/
|
||||
|
||||
/*
|
||||
Setup:
|
||||
|
||||
$db = NewADOConnection('text');
|
||||
$db->Connect($array,[$types],[$colnames]);
|
||||
|
||||
Parameter $array is the 2 dimensional array of data. The first row can contain the
|
||||
column names. If column names is not defined in first row, you MUST define $colnames,
|
||||
the 3rd parameter.
|
||||
|
||||
Parameter $types is optional. If defined, it should contain an array matching
|
||||
the number of columns in $array, with each element matching the correct type defined
|
||||
by MetaType: (B,C,I,L,N). If undefined, we will probe for $this->_proberows rows
|
||||
to guess the type. Only C,I and N are recognised.
|
||||
|
||||
Parameter $colnames is optional. If defined, it is an array that contains the
|
||||
column names of $array. If undefined, we assume the first row of $array holds the
|
||||
column names.
|
||||
|
||||
The Execute() function will return a recordset. The recordset works like a normal recordset.
|
||||
We have partial support for SQL parsing. We process the SQL using the following rules:
|
||||
|
||||
1. SQL order by's always work for the first column ordered. Subsequent cols are ignored
|
||||
|
||||
2. All operations take place on the same table. No joins possible. In fact the FROM clause
|
||||
is ignored! You can use any name for the table.
|
||||
|
||||
3. To simplify code, all columns are returned, except when selecting 1 column
|
||||
|
||||
$rs = $db->Execute('select col1,col2 from table'); // sql ignored, will generate all cols
|
||||
|
||||
We special case handling of 1 column because it is used in filter popups
|
||||
|
||||
$rs = $db->Execute('select col1 from table');
|
||||
// sql accepted and processed -- any table name is accepted
|
||||
|
||||
$rs = $db->Execute('select distinct col1 from table');
|
||||
// sql accepted and processed
|
||||
|
||||
4. Where clauses are ignored, but searching with the 3rd parameter of Execute is permitted.
|
||||
This has to use PHP syntax and we will eval() it. You can even use PHP functions.
|
||||
|
||||
$rs = $db->Execute('select * from table',false,"\$COL1='abc' and $\COL2=3")
|
||||
// the 3rd param is searched -- make sure that $COL1 is a legal column name
|
||||
// and all column names must be in upper case.
|
||||
|
||||
4. Group by, having, other clauses are ignored
|
||||
|
||||
5. Expression columns, min(), max() are ignored
|
||||
|
||||
6. All data is readonly. Only SELECTs permitted.
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
if (! defined("_ADODB_TEXT_LAYER")) {
|
||||
define("_ADODB_TEXT_LAYER", 1 );
|
||||
|
||||
// for sorting in _query()
|
||||
function adodb_cmp($a, $b) {
|
||||
if ($a[0] == $b[0]) return 0;
|
||||
return ($a[0] < $b[0]) ? -1 : 1;
|
||||
}
|
||||
// for sorting in _query()
|
||||
function adodb_cmpr($a, $b) {
|
||||
if ($a[0] == $b[0]) return 0;
|
||||
return ($a[0] > $b[0]) ? -1 : 1;
|
||||
}
|
||||
class ADODB_text extends ADOConnection {
|
||||
var $databaseType = 'text';
|
||||
|
||||
var $_origarray; // original data
|
||||
var $_types;
|
||||
var $_proberows = 8;
|
||||
var $_colnames;
|
||||
var $_skiprow1=false;
|
||||
var $readOnly = true;
|
||||
var $hasTransactions = false;
|
||||
|
||||
var $_rezarray;
|
||||
var $_reznames;
|
||||
var $_reztypes;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
function RSRecordCount()
|
||||
{
|
||||
if (!empty($this->_rezarray)) return sizeof($this->_rezarray);
|
||||
|
||||
return sizeof($this->_origarray);
|
||||
}
|
||||
|
||||
function _insertid()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
function _affectedrows()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function PConnect(&$array, $types = false, $colnames = false)
|
||||
{
|
||||
return $this->Connect($array, $types, $colnames);
|
||||
}
|
||||
// returns true or false
|
||||
function Connect(&$array, $types = false, $colnames = false)
|
||||
{
|
||||
if (is_string($array) and $array === 'iluvphplens') return 'me2';
|
||||
|
||||
if (!$array) {
|
||||
$this->_origarray = false;
|
||||
return true;
|
||||
}
|
||||
$row = $array[0];
|
||||
$cols = sizeof($row);
|
||||
|
||||
|
||||
if ($colnames) $this->_colnames = $colnames;
|
||||
else {
|
||||
$this->_colnames = $array[0];
|
||||
$this->_skiprow1 = true;
|
||||
}
|
||||
if (!$types) {
|
||||
// probe and guess the type
|
||||
$types = array();
|
||||
$firstrow = true;
|
||||
if ($this->_proberows > sizeof($array)) $max = sizeof($array);
|
||||
else $max = $this->_proberows;
|
||||
for ($j=($this->_skiprow1)?1:0;$j < $max; $j++) {
|
||||
$row = $array[$j];
|
||||
if (!$row) break;
|
||||
$i = -1;
|
||||
foreach($row as $v) {
|
||||
$i += 1;
|
||||
//print " ($i ".$types[$i]. "$v) ";
|
||||
$v = trim($v);
|
||||
if (!preg_match('/^[+-]{0,1}[0-9\.]+$/',$v)) {
|
||||
$types[$i] = 'C'; // once C, always C
|
||||
continue;
|
||||
}
|
||||
if (isset($types[$i]) && $types[$i]=='C') continue;
|
||||
if ($firstrow) {
|
||||
// If empty string, we presume is character
|
||||
// test for integer for 1st row only
|
||||
// after that it is up to testing other rows to prove
|
||||
// that it is not an integer
|
||||
if (strlen($v) == 0) $types[0] = 'C';
|
||||
if (strpos($v,'.') !== false) $types[0] = 'N';
|
||||
else $types[$i] = 'I';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strpos($v,'.') !== false) $types[$i] = 'N';
|
||||
|
||||
}
|
||||
$firstrow = false;
|
||||
}
|
||||
}
|
||||
//print_r($types);
|
||||
$this->_origarray = $array;
|
||||
$this->_types = $types;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// returns queryID or false
|
||||
// We presume that the select statement is on the same table (what else?),
|
||||
// with the only difference being the order by.
|
||||
//You can filter by using $eval and each clause is stored in $arr .eg. $arr[1] == 'name'
|
||||
// also supports SELECT [DISTINCT] COL FROM ... -- only 1 col supported
|
||||
function _query($sql,$input_arr,$eval=false)
|
||||
{
|
||||
if ($this->_origarray === false) return false;
|
||||
|
||||
$eval = $this->evalAll;
|
||||
$usql = strtoupper(trim($sql));
|
||||
$usql = preg_replace("/[\t\n\r]/",' ',$usql);
|
||||
$usql = preg_replace('/ *BY/i',' BY',strtoupper($usql));
|
||||
|
||||
$eregword ='([A-Z_0-9]*)';
|
||||
//print "<BR> $sql $eval ";
|
||||
if ($eval) {
|
||||
$i = 0;
|
||||
foreach($this->_colnames as $n) {
|
||||
$n = strtoupper(trim($n));
|
||||
$eval = str_replace("\$$n","\$arr[$i]",$eval);
|
||||
|
||||
$i += 1;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$eval = "\$rez=($eval);";
|
||||
//print "<p>Eval string = $eval </p>";
|
||||
$where_arr = array();
|
||||
|
||||
reset($this->_origarray);
|
||||
while (list($k_arr,$arr) = each($this->_origarray)) {
|
||||
|
||||
if ($i == 0 && $this->_skiprow1)
|
||||
$where_arr[] = $arr;
|
||||
else {
|
||||
eval($eval);
|
||||
//print " $i: result=$rez arr[0]={$arr[0]} arr[1]={$arr[1]} <BR>\n ";
|
||||
if ($rez) $where_arr[] = $arr;
|
||||
}
|
||||
$i += 1;
|
||||
}
|
||||
$this->_rezarray = $where_arr;
|
||||
}else
|
||||
$where_arr = $this->_origarray;
|
||||
|
||||
// THIS PROJECTION CODE ONLY WORKS FOR 1 COLUMN,
|
||||
// OTHERWISE IT RETURNS ALL COLUMNS
|
||||
if (substr($usql,0,7) == 'SELECT ') {
|
||||
$at = strpos($usql,' FROM ');
|
||||
$sel = trim(substr($usql,7,$at-7));
|
||||
|
||||
$distinct = false;
|
||||
if (substr($sel,0,8) == 'DISTINCT') {
|
||||
$distinct = true;
|
||||
$sel = trim(substr($sel,8,$at));
|
||||
}
|
||||
|
||||
// $sel holds the selection clause, comma delimited
|
||||
// currently we only project if one column is involved
|
||||
// this is to support popups in PHPLens
|
||||
if (strpos(',',$sel)===false) {
|
||||
$colarr = array();
|
||||
|
||||
preg_match("/$eregword/",$sel,$colarr);
|
||||
$col = $colarr[1];
|
||||
$i = 0;
|
||||
$n = '';
|
||||
reset($this->_colnames);
|
||||
while (list($k_n,$n) = each($this->_colnames)) {
|
||||
|
||||
if ($col == strtoupper(trim($n))) break;
|
||||
$i += 1;
|
||||
}
|
||||
|
||||
if ($n && $col) {
|
||||
$distarr = array();
|
||||
$projarray = array();
|
||||
$projtypes = array($this->_types[$i]);
|
||||
$projnames = array($n);
|
||||
|
||||
reset($where_arr);
|
||||
while (list($k_a,$a) = each($where_arr)) {
|
||||
if ($i == 0 && $this->_skiprow1) {
|
||||
$projarray[] = array($n);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($distinct) {
|
||||
$v = strtoupper($a[$i]);
|
||||
if (! $distarr[$v]) {
|
||||
$projarray[] = array($a[$i]);
|
||||
$distarr[$v] = 1;
|
||||
}
|
||||
} else
|
||||
$projarray[] = array($a[$i]);
|
||||
|
||||
} //foreach
|
||||
//print_r($projarray);
|
||||
}
|
||||
} // check 1 column in projection
|
||||
} // is SELECT
|
||||
|
||||
if (empty($projarray)) {
|
||||
$projtypes = $this->_types;
|
||||
$projarray = $where_arr;
|
||||
$projnames = $this->_colnames;
|
||||
}
|
||||
$this->_rezarray = $projarray;
|
||||
$this->_reztypes = $projtypes;
|
||||
$this->_reznames = $projnames;
|
||||
|
||||
|
||||
$pos = strpos($usql,' ORDER BY ');
|
||||
if ($pos === false) return $this;
|
||||
$orderby = trim(substr($usql,$pos+10));
|
||||
|
||||
preg_match("/$eregword/",$orderby,$arr);
|
||||
if (sizeof($arr) < 2) return $this; // actually invalid sql
|
||||
$col = $arr[1];
|
||||
$at = (integer) $col;
|
||||
if ($at == 0) {
|
||||
$i = 0;
|
||||
reset($projnames);
|
||||
while (list($k_n,$n) = each($projnames)) {
|
||||
if (strtoupper(trim($n)) == $col) {
|
||||
$at = $i+1;
|
||||
break;
|
||||
}
|
||||
$i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($at <= 0 || $at > sizeof($projarray[0])) return $this; // cannot find sort column
|
||||
$at -= 1;
|
||||
|
||||
// generate sort array consisting of (sortval1, row index1) (sortval2, row index2)...
|
||||
$sorta = array();
|
||||
$t = $projtypes[$at];
|
||||
$num = ($t == 'I' || $t == 'N');
|
||||
for ($i=($this->_skiprow1)?1:0, $max = sizeof($projarray); $i < $max; $i++) {
|
||||
$row = $projarray[$i];
|
||||
$val = ($num)?(float)$row[$at]:$row[$at];
|
||||
$sorta[]=array($val,$i);
|
||||
}
|
||||
|
||||
// check for desc sort
|
||||
$orderby = substr($orderby,strlen($col)+1);
|
||||
$arr == array();
|
||||
preg_match('/([A-Z_0-9]*)/i',$orderby,$arr);
|
||||
|
||||
if (trim($arr[1]) == 'DESC') $sortf = 'adodb_cmpr';
|
||||
else $sortf = 'adodb_cmp';
|
||||
|
||||
// hasta la sorta babe
|
||||
usort($sorta, $sortf);
|
||||
|
||||
// rearrange original array
|
||||
$arr2 = array();
|
||||
if ($this->_skiprow1) $arr2[] = $projarray[0];
|
||||
foreach($sorta as $v) {
|
||||
$arr2[] = $projarray[$v[1]];
|
||||
}
|
||||
|
||||
$this->_rezarray = $arr2;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/* Returns: the last error message from previous database operation */
|
||||
function ErrorMsg()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Returns: the last error number from previous database operation */
|
||||
function ErrorNo()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns true or false
|
||||
function _close()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------------------
|
||||
Class Name: Recordset
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
class ADORecordSet_text extends ADORecordSet_array
|
||||
{
|
||||
|
||||
var $databaseType = "text";
|
||||
|
||||
function __construct(&$conn,$mode=false)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->InitArray($conn->_rezarray,$conn->_reztypes,$conn->_reznames);
|
||||
$conn->_rezarray = false;
|
||||
}
|
||||
|
||||
} // class ADORecordSet_text
|
||||
|
||||
|
||||
} // defined
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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.
|
||||
@@ -34,11 +36,6 @@ class ADODB_vfp extends ADODB_odbc {
|
||||
var $hasTransactions = false;
|
||||
var $curmode = false ; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
|
||||
|
||||
function ADODB_vfp()
|
||||
{
|
||||
$this->ADODB_odbc();
|
||||
}
|
||||
|
||||
function Time()
|
||||
{
|
||||
return time();
|
||||
@@ -72,12 +69,12 @@ class ADORecordSet_vfp extends ADORecordSet_odbc {
|
||||
var $databaseType = "vfp";
|
||||
|
||||
|
||||
function ADORecordSet_vfp($id,$mode=false)
|
||||
function __construct($id,$mode=false)
|
||||
{
|
||||
return $this->ADORecordSet_odbc($id,$mode);
|
||||
return parent::__construct($id,$mode);
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1)
|
||||
function MetaType($t, $len = -1, $fieldobj = false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
|
||||
+416
-102
@@ -1,182 +1,496 @@
|
||||
ADOdb is dual licensed using BSD and LGPL.
|
||||
ADOdb License
|
||||
=============
|
||||
|
||||
In plain English, you do not need to distribute your application in source code form, nor do you need to distribute ADOdb source code, provided you follow the rest of terms of the BSD license.
|
||||
ADOdb is dual licensed under BSD and LGPL.
|
||||
|
||||
In plain English, you do not need to distribute your application in source code form,
|
||||
nor do you need to distribute ADOdb source code, provided you follow the rest of
|
||||
terms of the BSD license.
|
||||
|
||||
For more info about ADOdb, visit http://adodb.sourceforge.net/
|
||||
|
||||
BSD Style-License
|
||||
=================
|
||||
BSD 3-Clause License
|
||||
--------------------
|
||||
|
||||
Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim
|
||||
(c) 2000-2013 John Lim ([email protected])
|
||||
(c) 2014 Damien Regad, Mark Newnham and the ADOdb community
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
Neither the name of the John Lim nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior written
|
||||
permission.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
DISCLAIMER:
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
JOHN LIM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
### DISCLAIMER
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
==========================================================
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
---------------------------------
|
||||
|
||||
_Version 2.1, February 1999_
|
||||
_Copyright © 1991, 1999 Free Software Foundation, Inc._
|
||||
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
_This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1._
|
||||
|
||||
### Preamble
|
||||
|
||||
Preamble
|
||||
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
|
||||
We protect your rights with a two-step method: **(1)** we copyright the
|
||||
library, and **(2)** we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
|
||||
We call this license the “Lesser” General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
“work based on the library” and a “work that uses the library”. The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
|
||||
**0.** This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called “this License”).
|
||||
Each licensee is addressed as “you”.
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
|
||||
A “library” means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
|
||||
The “Library”, below, refers to any such software library or work
|
||||
which has been distributed under these terms. A “work based on the
|
||||
Library” means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term “modification”.)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
|
||||
“Source code” for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
|
||||
**1.** You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
||||
**2.** You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
* **a)** The modified work must itself be a software library.
|
||||
* **b)** You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
* **c)** You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
* **d)** If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
|
||||
c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
|
||||
d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
|
||||
(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
||||
**3.** You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
|
||||
**4.** You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
|
||||
**5.** A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a “work that uses the Library”. Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
|
||||
However, linking a “work that uses the Library” with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a “work that uses the
|
||||
library”. The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
|
||||
When a “work that uses the Library” uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
|
||||
**6.** As an exception to the Sections above, you may also combine or
|
||||
link a “work that uses the Library” with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
|
||||
* **a)** Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable “work that
|
||||
uses the Library”, as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
* **b)** Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
* **c)** Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
* **d)** If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
* **e)** Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the “work that uses the
|
||||
Library” must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
|
||||
b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
|
||||
c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
|
||||
d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
|
||||
e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
|
||||
For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
|
||||
**7.** You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
|
||||
* **a)** Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
* **b)** Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
**8.** You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
|
||||
b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
||||
**9.** You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
|
||||
**10.** Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
|
||||
**11.** If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
||||
**12.** If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
||||
**13.** The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
“any later version”, you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
|
||||
**14.** If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
||||
### NO WARRANTY
|
||||
|
||||
NO WARRANTY
|
||||
**15.** BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY “AS IS” WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
**16.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
_END OF TERMS AND CONDITIONS_
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -56,7 +58,7 @@ class perf_db2 extends adodb_perf{
|
||||
);
|
||||
|
||||
|
||||
function perf_db2(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -61,7 +63,7 @@ class perf_informix extends adodb_perf{
|
||||
|
||||
);
|
||||
|
||||
function perf_informix(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -65,7 +67,7 @@ class perf_mssql extends adodb_perf{
|
||||
);
|
||||
|
||||
|
||||
function perf_mssql(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
if ($conn->dataProvider == 'odbc') {
|
||||
$this->sql1 = 'sql1';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -65,7 +67,7 @@ class perf_mssqlnative extends adodb_perf{
|
||||
);
|
||||
|
||||
|
||||
function perf_mssqlnative(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
if ($conn->dataProvider == 'odbc') {
|
||||
$this->sql1 = 'sql1';
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -81,7 +83,7 @@ class perf_mysql extends adodb_perf{
|
||||
false
|
||||
);
|
||||
|
||||
function perf_mysql(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -198,7 +200,7 @@ FROM v\$parameter v1, v\$parameter v2 WHERE v1.name='log_archive_dest' AND v2.na
|
||||
);
|
||||
|
||||
|
||||
function perf_oci8(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
global $gSQLBlockRows;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
|
||||
@version v5.20.1 06-Dec-2015
|
||||
@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. See License.txt.
|
||||
@@ -87,7 +89,7 @@ class perf_postgres extends adodb_perf{
|
||||
false
|
||||
);
|
||||
|
||||
function perf_postgres(&$conn)
|
||||
function __construct(&$conn)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user