summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/adodb-access.inc.php24
-rw-r--r--drivers/adodb-ado.inc.php6
-rw-r--r--drivers/adodb-ado5.inc.php6
-rw-r--r--drivers/adodb-ado_access.inc.php10
-rw-r--r--drivers/adodb-ado_mssql.inc.php62
-rw-r--r--drivers/adodb-borland_ibase.inc.php6
-rw-r--r--drivers/adodb-csv.inc.php16
-rw-r--r--drivers/adodb-db2.inc.php2
-rw-r--r--drivers/adodb-db2oci.inc.php52
-rw-r--r--drivers/adodb-db2ora.inc.php8
-rw-r--r--drivers/adodb-fbsql.inc.php8
-rw-r--r--drivers/adodb-firebird.inc.php884
-rw-r--r--drivers/adodb-ibase.inc.php4
-rw-r--r--drivers/adodb-informix.inc.php7
-rw-r--r--drivers/adodb-informix72.inc.php2
-rw-r--r--drivers/adodb-ldap.inc.php8
-rw-r--r--drivers/adodb-mssql.inc.php267
-rw-r--r--drivers/adodb-mssql_n.inc.php58
-rw-r--r--drivers/adodb-mssqlnative.inc.php470
-rw-r--r--drivers/adodb-mssqlpo.inc.php6
-rw-r--r--drivers/adodb-mysql.inc.php39
-rw-r--r--drivers/adodb-mysqli.inc.php106
-rw-r--r--drivers/adodb-mysqlpo.inc.php16
-rw-r--r--drivers/adodb-mysqlt.inc.php7
-rw-r--r--drivers/adodb-netezza.inc.php12
-rw-r--r--drivers/adodb-oci8.inc.php14
-rw-r--r--drivers/adodb-oci805.inc.php6
-rw-r--r--drivers/adodb-oci8po.inc.php8
-rw-r--r--drivers/adodb-oci8quercus.inc.php11
-rw-r--r--drivers/adodb-odbc.inc.php30
-rw-r--r--drivers/adodb-odbc_db2.inc.php11
-rw-r--r--drivers/adodb-odbc_mssql.inc.php64
-rw-r--r--drivers/adodb-odbc_mssql2012.inc.php28
-rw-r--r--drivers/adodb-odbc_oracle.inc.php8
-rw-r--r--drivers/adodb-odbtp.inc.php26
-rw-r--r--drivers/adodb-odbtp_unicode.inc.php4
-rw-r--r--drivers/adodb-oracle.inc.php6
-rw-r--r--drivers/adodb-pdo.inc.php23
-rw-r--r--drivers/adodb-pdo_mssql.inc.php2
-rw-r--r--drivers/adodb-pdo_mysql.inc.php2
-rw-r--r--drivers/adodb-pdo_oci.inc.php2
-rw-r--r--drivers/adodb-pdo_pgsql.inc.php62
-rw-r--r--drivers/adodb-pdo_sqlite.inc.php2
-rw-r--r--drivers/adodb-pdo_sqlsrv.inc.php117
-rw-r--r--drivers/adodb-postgres.inc.php2
-rw-r--r--drivers/adodb-postgres64.inc.php77
-rw-r--r--drivers/adodb-postgres7.inc.php13
-rw-r--r--drivers/adodb-postgres8.inc.php2
-rw-r--r--drivers/adodb-postgres9.inc.php2
-rw-r--r--drivers/adodb-proxy.inc.php23
-rw-r--r--drivers/adodb-sapdb.inc.php76
-rw-r--r--drivers/adodb-sqlanywhere.inc.php9
-rw-r--r--drivers/adodb-sqlite.inc.php63
-rw-r--r--drivers/adodb-sqlite3.inc.php208
-rw-r--r--drivers/adodb-sqlitepo.inc.php7
-rw-r--r--drivers/adodb-sybase.inc.php14
-rw-r--r--drivers/adodb-sybase_ase.inc.php13
-rw-r--r--drivers/adodb-text.inc.php6
-rw-r--r--drivers/adodb-vfp.inc.php11
59 files changed, 2213 insertions, 825 deletions
diff --git a/drivers/adodb-access.inc.php b/drivers/adodb-access.inc.php
index 051aab87..2d0048f3 100644
--- a/drivers/adodb-access.inc.php
+++ b/drivers/adodb-access.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -15,10 +15,11 @@
if (!defined('_ADODB_ODBC_LAYER')) {
if (!defined('ADODB_DIR')) die();
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
- if (!defined('_ADODB_ACCESS')) {
- define('_ADODB_ACCESS',1);
+
+if (!defined('_ADODB_ACCESS')) {
+ define('_ADODB_ACCESS',1);
class ADODB_access extends ADODB_odbc {
var $databaseType = 'access';
@@ -31,14 +32,6 @@ class ADODB_access extends ADODB_odbc {
var $hasTransactions = false;
var $upperCase = 'ucase';
- function __construct()
- {
- global $ADODB_EXTENSION;
-
- $ADODB_EXTENSION = false;
- parent::__construct();
- }
-
function Time()
{
return time();
@@ -80,9 +73,6 @@ class ADORecordSet_access extends ADORecordSet_odbc {
var $databaseType = "access";
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
-}// class
+} // class
+
}
diff --git a/drivers/adodb-ado.inc.php b/drivers/adodb-ado.inc.php
index dade2f71..32f251cb 100644
--- a/drivers/adodb-ado.inc.php
+++ b/drivers/adodb-ado.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -350,7 +350,7 @@ class ADORecordSet_ado extends ADORecordSet {
$mode = $ADODB_FETCH_MODE;
}
$this->fetchMode = $mode;
- return parent::__construct($id,$mode);
+ return parent::__construct($id);
}
@@ -538,7 +538,7 @@ class ADORecordSet_ado extends ADORecordSet {
case 19://adUnsignedInt = 19,
case 20://adUnsignedBigInt = 21,
return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
diff --git a/drivers/adodb-ado5.inc.php b/drivers/adodb-ado5.inc.php
index d3b42d44..e58fed8f 100644
--- a/drivers/adodb-ado5.inc.php
+++ b/drivers/adodb-ado5.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -384,7 +384,7 @@ class ADORecordSet_ado extends ADORecordSet {
$mode = $ADODB_FETCH_MODE;
}
$this->fetchMode = $mode;
- return parent::__construct($id,$mode);
+ return parent::__construct($id);
}
@@ -579,7 +579,7 @@ class ADORecordSet_ado extends ADORecordSet {
case 19://adUnsignedInt = 19,
case 20://adUnsignedBigInt = 21,
return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
diff --git a/drivers/adodb-ado_access.inc.php b/drivers/adodb-ado_access.inc.php
index 5f19b547..117b0363 100644
--- a/drivers/adodb-ado_access.inc.php
+++ b/drivers/adodb-ado_access.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -17,8 +17,8 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ADO_LAYER')) {
- if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
- else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
+ if (PHP_VERSION >= 5) include_once(ADODB_DIR."/drivers/adodb-ado5.inc.php");
+ else include_once(ADODB_DIR."/drivers/adodb-ado.inc.php");
}
class ADODB_ado_access extends ADODB_ado {
@@ -43,8 +43,4 @@ class ADORecordSet_ado_access extends ADORecordSet_ado {
var $databaseType = "ado_access";
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-ado_mssql.inc.php b/drivers/adodb-ado_mssql.inc.php
index c3203da2..6923b850 100644
--- a/drivers/adodb-ado_mssql.inc.php
+++ b/drivers/adodb-ado_mssql.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -21,8 +21,8 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ADO_LAYER')) {
- if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
- else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
+ if (PHP_VERSION >= 5) include_once(ADODB_DIR."/drivers/adodb-ado5.inc.php");
+ else include_once(ADODB_DIR."/drivers/adodb-ado.inc.php");
}
@@ -43,12 +43,12 @@ class ADODB_ado_mssql extends ADODB_ado {
function _insertid()
{
- return $this->GetOne('select SCOPE_IDENTITY()');
+ return $this->GetOne('select SCOPE_IDENTITY()');
}
function _affectedrows()
{
- return $this->GetOne('select @@rowcount');
+ return $this->GetOne('select @@rowcount');
}
function SetTransactionMode( $transaction_mode )
@@ -70,32 +70,32 @@ class ADODB_ado_mssql extends ADODB_ado {
function MetaColumns($table, $normalize=true)
{
- $table = strtoupper($table);
- $arr= array();
- $dbc = $this->_connectionID;
+ $table = strtoupper($table);
+ $arr= array();
+ $dbc = $this->_connectionID;
- $osoptions = array();
- $osoptions[0] = null;
- $osoptions[1] = null;
- $osoptions[2] = $table;
- $osoptions[3] = null;
+ $osoptions = array();
+ $osoptions[0] = null;
+ $osoptions[1] = null;
+ $osoptions[2] = $table;
+ $osoptions[3] = null;
- $adors=@$dbc->OpenSchema(4, $osoptions);//tables
+ $adors=@$dbc->OpenSchema(4, $osoptions);//tables
- if ($adors){
- while (!$adors->EOF){
- $fld = new ADOFieldObject();
- $c = $adors->Fields(3);
- $fld->name = $c->Value;
- $fld->type = 'CHAR'; // cannot discover type in ADO!
- $fld->max_length = -1;
- $arr[strtoupper($fld->name)]=$fld;
+ if ($adors){
+ while (!$adors->EOF){
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
- $adors->MoveNext();
- }
- $adors->Close();
- }
- $false = false;
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+ $false = false;
return empty($arr) ? $false : $arr;
}
@@ -137,14 +137,10 @@ class ADODB_ado_mssql extends ADODB_ado {
//return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'");
}
- } // end class
+} // end class
- class ADORecordSet_ado_mssql extends ADORecordSet_ado {
+class ADORecordSet_ado_mssql extends ADORecordSet_ado {
var $databaseType = 'ado_mssql';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-borland_ibase.inc.php b/drivers/adodb-borland_ibase.inc.php
index 70c30fbb..20af24d3 100644
--- a/drivers/adodb-borland_ibase.inc.php
+++ b/drivers/adodb-borland_ibase.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -82,8 +82,4 @@ class ADORecordSet_borland_ibase extends ADORecordSet_ibase {
var $databaseType = "borland_ibase";
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-csv.inc.php b/drivers/adodb-csv.inc.php
index 61fad92a..69de8cbc 100644
--- a/drivers/adodb-csv.inc.php
+++ b/drivers/adodb-csv.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -38,18 +38,14 @@ class ADODB_csv extends ADOConnection {
var $hasTransactions = false;
var $_errorNo = false;
- function __construct()
- {
- }
-
function _insertid()
{
- return $this->_insertid;
+ return $this->_insertid;
}
function _affectedrows()
{
- return $this->_affectedrows;
+ return $this->_affectedrows;
}
function MetaDatabases()
@@ -178,7 +174,7 @@ class ADODB_csv extends ADOConnection {
/* Returns: the last error message from previous database operation */
function ErrorMsg()
{
- return $this->_errorMsg;
+ return $this->_errorMsg;
}
/* Returns: the last error number from previous database operation */
@@ -195,10 +191,6 @@ class ADODB_csv extends ADOConnection {
} // class
class ADORecordset_csv extends ADORecordset {
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
function _close()
{
diff --git a/drivers/adodb-db2.inc.php b/drivers/adodb-db2.inc.php
index c42fef69..d5b92665 100644
--- a/drivers/adodb-db2.inc.php
+++ b/drivers/adodb-db2.inc.php
@@ -1,6 +1,6 @@
<?php
/**
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
diff --git a/drivers/adodb-db2oci.inc.php b/drivers/adodb-db2oci.inc.php
index ea57a0d2..0ca5209e 100644
--- a/drivers/adodb-db2oci.inc.php
+++ b/drivers/adodb-db2oci.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -15,49 +15,19 @@ Set tabs to 4 for best viewing.
// security - hide paths
if (!defined('ADODB_DIR')) die();
-include(ADODB_DIR."/drivers/adodb-db2.inc.php");
+include_once(ADODB_DIR."/drivers/adodb-db2.inc.php");
if (!defined('ADODB_DB2OCI')){
define('ADODB_DB2OCI',1);
-/*
-// regex code for smart remapping of :0, :1 bind vars to ? ?
-function _colontrack($p)
-{
-global $_COLONARR,$_COLONSZ;
- $v = (integer) substr($p,1);
- if ($v > $_COLONSZ) return $p;
- $_COLONARR[] = $v;
- return '?';
-}
-
-// smart remapping of :0, :1 bind vars to ? ?
-function _colonscope($sql,$arr)
-{
-global $_COLONARR,$_COLONSZ;
-
- $_COLONARR = array();
- $_COLONSZ = sizeof($arr);
-
- $sql2 = preg_replace("/(:[0-9]+)/e","_colontrack('\\1')",$sql);
-
- if (empty($_COLONARR)) return array($sql,$arr);
-
- foreach($_COLONARR as $k => $v) {
- $arr2[] = $arr[$v];
- }
-
- return array($sql2,$arr2);
-}
-*/
-
-/*
- Smart remapping of :0, :1 bind vars to ? ?
-
- Handles colons in comments -- and / * * / and in quoted strings.
-*/
-
+/**
+ * Smart remapping of :0, :1 bind vars to ? ?
+ * Handles colons in comments -- and / * * / and in quoted strings.
+ * @param string $sql SQL statement
+ * @param array $arr parameters
+ * @return array
+ */
function _colonparser($sql,$arr)
{
$lensql = strlen($sql);
@@ -217,10 +187,6 @@ class ADORecordSet_db2oci extends ADORecordSet_db2 {
var $databaseType = "db2oci";
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
} //define
diff --git a/drivers/adodb-db2ora.inc.php b/drivers/adodb-db2ora.inc.php
index f30a4aea..c3a8c1d2 100644
--- a/drivers/adodb-db2ora.inc.php
+++ b/drivers/adodb-db2ora.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -15,7 +15,7 @@ Set tabs to 4 for best viewing.
// security - hide paths
if (!defined('ADODB_DIR')) die();
-include(ADODB_DIR."/drivers/adodb-db2.inc.php");
+include_once(ADODB_DIR."/drivers/adodb-db2.inc.php");
if (!defined('ADODB_DB2OCI')){
@@ -77,10 +77,6 @@ class ADORecordSet_db2oci extends ADORecordSet_odbc {
var $databaseType = "db2oci";
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
} //define
diff --git a/drivers/adodb-fbsql.inc.php b/drivers/adodb-fbsql.inc.php
index 40143ecb..c5c5f5a8 100644
--- a/drivers/adodb-fbsql.inc.php
+++ b/drivers/adodb-fbsql.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -25,10 +25,6 @@ class ADODB_fbsql extends ADOConnection {
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasLimit = false;
- function __construct()
- {
- }
-
function _insertid()
{
return fbsql_insert_id($this->_connectionID);
@@ -259,7 +255,7 @@ class ADORecordSet_fbsql extends ADORecordSet{
if (!empty($fieldobj->primary_key)) return 'R';
else return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php
index c298f49a..a1b7f9ac 100644
--- a/drivers/adodb-firebird.inc.php
+++ b/drivers/adodb-firebird.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -10,18 +10,114 @@ Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
+ firebird data driver. Requires firebird client. Works on Windows and Unix.
+
*/
// security - hide paths
if (!defined('ADODB_DIR')) die();
-include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
-
-class ADODB_firebird extends ADODB_ibase {
+class ADODB_firebird extends ADOConnection {
var $databaseType = "firebird";
+ var $dataProvider = "firebird";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $fbird_datefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S';
+ var $fmtDate = "'Y-m-d'";
+ var $fbird_timestampfmt = "%Y-%m-%d %H:%M:%S";
+ var $fbird_timefmt = "%H:%M:%S";
+ var $fmtTimeStamp = "'Y-m-d, H:i:s'";
+ var $concat_operator='||';
+ var $_transactionID;
+ var $metaTablesSQL = "select lower(rdb\$relation_name) from rdb\$relations where rdb\$relation_name not like 'RDB\$%'";
+ //OPN STUFF start
+ var $metaColumnsSQL = "select lower(a.rdb\$field_name), a.rdb\$null_flag, a.rdb\$default_source, b.rdb\$field_length, b.rdb\$field_scale, b.rdb\$field_sub_type, b.rdb\$field_precision, b.rdb\$field_type from rdb\$relation_fields a, rdb\$fields b where a.rdb\$field_source = b.rdb\$field_name and a.rdb\$relation_name = '%s' order by a.rdb\$field_position asc";
+ //OPN STUFF end
+ var $ibasetrans;
+ var $hasGenID = true;
+ var $_bindInputArray = true;
+ var $buffers = 0;
var $dialect = 3;
-
+ var $sysDate = "cast('TODAY' as timestamp)";
var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)";
+ var $ansiOuter = true;
+ var $hasAffectedRows = true;
+ var $poorAffectedRows = false;
+ var $blobEncodeType = 'C';
+ var $role = false;
+ var $nameQuote = ''; /// string to use to quote identifiers and names
+
+ function __construct()
+ {
+ // Ignore IBASE_DEFAULT we want a more practical transaction!
+ // if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
+ // else
+ $this->ibasetrans = IBASE_WAIT | IBASE_REC_VERSION | IBASE_COMMITTED;
+ }
+
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
+ {
+ if (!function_exists('fbird_pconnect')) return null;
+ if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
+ $fn = ($persist) ? 'fbird_pconnect':'fbird_connect';
+ if ($this->role)
+ $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
+ $this->charSet,$this->buffers,$this->dialect,$this->role);
+ else
+ $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
+ $this->charSet,$this->buffers,$this->dialect);
+
+ if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
+ $this->replaceQuote = "''";
+ }
+ if ($this->_connectionID === false) {
+ $this->_handleerror();
+ return false;
+ }
+
+ // PHP5 change.
+ if (function_exists('fbird_timefmt')) {
+ fbird_timefmt($this->fbird_datefmt,fbird_DATE );
+ if ($this->dialect == 1) {
+ fbird_timefmt($this->fbird_datefmt,fbird_TIMESTAMP );
+ } else {
+ fbird_timefmt($this->fbird_timestampfmt,fbird_TIMESTAMP );
+ }
+ fbird_timefmt($this->fbird_timefmt,fbird_TIME );
+
+ } else {
+ ini_set("ibase.timestampformat", $this->fbird_timestampfmt);
+ ini_set("ibase.dateformat", $this->fbird_datefmt);
+ ini_set("ibase.timeformat", $this->fbird_timefmt);
+ }
+ return true;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
+ }
+
+
+ function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
+ {
+ if ($internalKey) {
+ return array('RDB$DB_KEY');
+ }
+
+ $table = strtoupper($table);
+
+ $sql = 'SELECT S.RDB$FIELD_NAME AFIELDNAME
+ FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON I.RDB$INDEX_NAME=S.RDB$INDEX_NAME
+ WHERE I.RDB$RELATION_NAME=\''.$table.'\' and I.RDB$INDEX_NAME like \'RDB$PRIMARY%\'
+ ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION';
+
+ $a = $this->GetCol($sql,false,true);
+ if ($a && sizeof($a)>0) return $a;
+ return false;
+ }
function ServerInfo()
{
@@ -38,10 +134,621 @@ class ADODB_firebird extends ADODB_ibase {
return $arr;
}
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->autoCommit = false;
+ $this->_transactionID = fbird_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;
+ }
+ $ret = false;
+ $this->autoCommit = true;
+ if ($this->_transactionID) {
+ //print ' commit ';
+ $ret = fbird_commit($this->_transactionID);
+ }
+ $this->_transactionID = false;
+ return $ret;
+ }
+
+ function _affectedrows()
+ {
+ return fbird_affected_rows( $this->_transactionID ? $this->_transactionID : $this->_connectionID );
+ }
+
+ // there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently.
+ // it appears that ibase extension cannot support multiple concurrent queryid's
+ function _Execute($sql,$inputarr=false) {
+ global $ADODB_COUNTRECS;
+
+ if ($this->_logsql) {
+ $savecrecs = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = true; // force countrecs
+ $ret =& ADOConnection::_Execute($sql,$inputarr);
+ $ADODB_COUNTRECS = $savecrecs;
+ } else {
+ $ret = ADOConnection::_Execute($sql,$inputarr);
+ }
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $ret = false;
+ $this->autoCommit = true;
+ if ($this->_transactionID) {
+ $ret = fbird_rollback($this->_transactionID);
+ }
+ $this->_transactionID = false;
+
+ return $ret;
+ }
+
+ 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;
+ }
+
+ $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()
+ );
+ }
+ $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];
+ }
+ }
+ // restore fetchmode
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ return $indexes;
+ }
+
+
+ // See http://community.borland.com/article/0,1410,25844,00.html
+ function RowLock($tables,$where,$col=false)
+ {
+ if ($this->autoCommit) {
+ $this->BeginTrans();
+ }
+ $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
+ return 1;
+ }
+
+
+ function CreateSequence($seqname = 'adodbseq', $startID = 1)
+ {
+ $ok = $this->Execute(("CREATE GENERATOR $seqname" ));
+ if (!$ok) return false;
+ return $this->Execute("SET GENERATOR $seqname TO ".($startID-1));
+ }
+
+ function DropSequence($seqname = 'adodbseq')
+ {
+ $seqname = strtoupper($seqname);
+ return $this->Execute("DROP GENERATOR $seqname");
+ }
+
+ function GenID($seqname='adodbseq',$startID=1)
+ {
+ $getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE");
+ $rs = @$this->Execute($getnext);
+ if (!$rs) {
+ $this->Execute(("CREATE GENERATOR $seqname" ));
+ $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->Close();
+ }
+
+ return $this->genID;
+ }
+
+ function SelectDB($dbName)
+ {
+ return false;
+ }
+
+ function _handleerror()
+ {
+ $this->_errorMsg = fbird_errmsg();
+ }
+
+ function ErrorNo()
+ {
+ if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr)) return (integer) $arr[1];
+ else return 0;
+ }
+
+ function ErrorMsg()
+ {
+ return $this->_errorMsg;
+ }
+
+ function Prepare($sql)
+ {
+ $stmt = fbird_prepare($this->_connectionID,$sql);
+ if (!$stmt) return false;
+ 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?
+ function _query($sql,$iarr=false)
+ {
+ if ( !$this->isConnected() ) return false;
+ if (!$this->autoCommit && $this->_transactionID) {
+ $conn = $this->_transactionID;
+ $docommit = false;
+ } else {
+ $conn = $this->_connectionID;
+ $docommit = true;
+ }
+ if (is_array($sql)) {
+ $fn = 'fbird_execute';
+ $sql = $sql[1];
+ if (is_array($iarr)) {
+ if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
+ if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
+ $fnarr = array_merge( array($sql) , $iarr);
+ $ret = call_user_func_array($fn,$fnarr);
+ } else {
+ switch(sizeof($iarr)) {
+ case 1: $ret = $fn($sql,$iarr[0]); break;
+ case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break;
+ case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break;
+ case 4: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
+ case 5: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
+ case 6: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
+ case 7: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
+ default: ADOConnection::outp( "Too many parameters to ibase query $sql");
+ case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
+ }
+ }
+ } else $ret = $fn($sql);
+ } else {
+ $fn = 'fbird_query';
+ if (is_array($iarr)) {
+ if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
+ if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack
+ $fnarr = array_merge( array($conn,$sql) , $iarr);
+ $ret = call_user_func_array($fn,$fnarr);
+ } else {
+ switch(sizeof($iarr)) {
+ case 1: $ret = $fn($conn,$sql,$iarr[0]); break;
+ case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break;
+ case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break;
+ case 4: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
+ case 5: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
+ case 6: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
+ case 7: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
+ default: ADOConnection::outp( "Too many parameters to ibase query $sql");
+ case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
+ }
+ }
+ } else $ret = $fn($conn,$sql);
+ }
+ if ($docommit && $ret === true) {
+ fbird_commit($this->_connectionID);
+ }
+
+ $this->_handleerror();
+ return $ret;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if (!$this->autoCommit) {
+ @fbird_rollback($this->_connectionID);
+ }
+ return @fbird_close($this->_connectionID);
+ }
+
+ //OPN STUFF start
+ function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3)
+ {
+ $fscale = abs($fscale);
+ $fld->max_length = $flen;
+ $fld->scale = null;
+ switch($ftype){
+ case 7:
+ case 8:
+ if ($dialect3) {
+ 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';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ } // switch
+ } else {
+ if ($fscale !=0) {
+ $fld->type = 'decimal';
+ $fld->scale = $fscale;
+ $fld->max_length = ($ftype == 7 ? 4 : 9);
+ } else {
+ $fld->type = ($ftype == 7 ? 'smallint' : 'integer');
+ }
+ }
+ break;
+ case 16:
+ if ($dialect3) {
+ switch($fsubtype){
+ case 0:
+ $fld->type = 'decimal';
+ $fld->max_length = 18;
+ $fld->scale = 0;
+ break;
+ case 1:
+ $fld->type = 'numeric';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ case 2:
+ $fld->type = 'decimal';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ } // switch
+ }
+ break;
+ case 10:
+ $fld->type = 'float';
+ break;
+ case 14:
+ $fld->type = 'char';
+ break;
+ case 27:
+ if ($fscale !=0) {
+ $fld->type = 'decimal';
+ $fld->max_length = 15;
+ $fld->scale = 5;
+ } else {
+ $fld->type = 'double';
+ }
+ break;
+ case 35:
+ if ($dialect3) {
+ $fld->type = 'timestamp';
+ } else {
+ $fld->type = 'date';
+ }
+ break;
+ case 12:
+ $fld->type = 'date';
+ break;
+ case 13:
+ $fld->type = 'time';
+ break;
+ case 37:
+ $fld->type = 'varchar';
+ break;
+ case 40:
+ $fld->type = 'cstring';
+ break;
+ case 261:
+ $fld->type = 'blob';
+ $fld->max_length = -1;
+ break;
+ } // switch
+ }
+ //OPN STUFF end
+
+ // returns array of ADOFieldObjects for current table
+ function MetaColumns($table, $normalize=true)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+
+ $ADODB_FETCH_MODE = $save;
+ $false = false;
+ if ($rs === false) {
+ return $false;
+ }
+
+ $retarr = array();
+ //OPN STUFF start
+ $dialect3 = ($this->dialect==3 ? true : false);
+ //OPN STUFF end
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = trim($rs->fields[0]);
+ //OPN STUFF start
+ $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3);
+ if (isset($rs->fields[1]) && $rs->fields[1]) {
+ $fld->not_null = true;
+ }
+ if (isset($rs->fields[2])) {
+
+ $fld->has_default = true;
+ $d = substr($rs->fields[2],strlen('default '));
+ switch ($fld->type)
+ {
+ case 'smallint':
+ case 'integer': $fld->default_value = (int) $d; break;
+ case 'char':
+ case 'blob':
+ case 'text':
+ case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
+ case 'double':
+ case 'float': $fld->default_value = (float) $d; break;
+ default: $fld->default_value = $d; break;
+ }
+ // case 35:$tt = 'TIMESTAMP'; break;
+ }
+ if ((isset($rs->fields[5])) && ($fld->type == 'blob')) {
+ $fld->sub_type = $rs->fields[5];
+ } else {
+ $fld->sub_type = null;
+ }
+ //OPN STUFF end
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ if ( empty($retarr)) return $false;
+ else return $retarr;
+ }
+
+ function BlobEncode( $blob )
+ {
+ $blobid = fbird_blob_create( $this->_connectionID);
+ fbird_blob_add( $blobid, $blob );
+ return fbird_blob_close( $blobid );
+ }
+
+ // since we auto-decode all blob's since 2.42,
+ // BlobDecode should not do any transforms
+ function BlobDecode($blob)
+ {
+ return $blob;
+ }
+
+ // old blobdecode function
+ // still used to auto-decode all blob's
+ function _BlobDecode_old( $blob )
+ {
+ $blobid = fbird_blob_open($this->_connectionID, $blob );
+ $realblob = fbird_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet <kevinboillet@yahoo.fr>
+ while($string = fbird_blob_get($blobid, 8192)){
+ $realblob .= $string;
+ }
+ fbird_blob_close( $blobid );
+
+ return( $realblob );
+ }
+
+ function _BlobDecode( $blob )
+ {
+ if (ADODB_PHPVER >= 0x5000) {
+ $blob_data = fbird_blob_info($this->_connectionID, $blob );
+ $blobid = fbird_blob_open($this->_connectionID, $blob );
+ } else {
+ $blob_data = fbird_blob_info( $blob );
+ $blobid = fbird_blob_open( $blob );
+ }
+
+ if( $blob_data[0] > $this->maxblobsize ) {
+ $realblob = fbird_blob_get($blobid, $this->maxblobsize);
+
+ while($string = fbird_blob_get($blobid, 8192)) {
+ $realblob .= $string;
+ }
+ } else {
+ $realblob = fbird_blob_get($blobid, $blob_data[0]);
+ }
+
+ fbird_blob_close( $blobid );
+ return( $realblob );
+ }
+
+ function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
+ {
+ $fd = fopen($path,'rb');
+ if ($fd === false) return false;
+ $blob_id = fbird_blob_create($this->_connectionID);
+
+ /* fill with data */
+
+ while ($val = fread($fd,32768)){
+ fbird_blob_add($blob_id, $val);
+ }
+
+ /* close and get $blob_id_str for inserting into table */
+ $blob_id_str = fbird_blob_close($blob_id);
+
+ fclose($fd);
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
+ }
+
+ /*
+ Insert a null into the blob field of the table first.
+ Then use UpdateBlob to store the blob.
+
+ Usage:
+
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
+ */
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ $blob_id = fbird_blob_create($this->_connectionID);
+
+ // fbird_blob_add($blob_id, $val);
+
+ // replacement that solves the problem by which only the first modulus 64K /
+ // of $val are stored at the blob field ////////////////////////////////////
+ // Thx Abel Berenstein aberenstein#afip.gov.ar
+ $len = strlen($val);
+ $chunk_size = 32768;
+ $tail_size = $len % $chunk_size;
+ $n_chunks = ($len - $tail_size) / $chunk_size;
+
+ for ($n = 0; $n < $n_chunks; $n++) {
+ $start = $n * $chunk_size;
+ $data = substr($val, $start, $chunk_size);
+ fbird_blob_add($blob_id, $data);
+ }
+
+ if ($tail_size) {
+ $start = $n_chunks * $chunk_size;
+ $data = substr($val, $start, $tail_size);
+ fbird_blob_add($blob_id, $data);
+ }
+ // end replacement /////////////////////////////////////////////////////////
+
+ $blob_id_str = fbird_blob_close($blob_id);
+
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
+
+ }
+
+
+ function OldUpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ $blob_id = fbird_blob_create($this->_connectionID);
+ fbird_blob_add($blob_id, $val);
+ $blob_id_str = fbird_blob_close($blob_id);
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
+ }
+
+ // Format date column in sql string given an input format that understands Y M D
+ // Only since Interbase 6.0 - uses EXTRACT
+ // problem - does not zero-fill the day and month yet
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysDate;
+ $s = '';
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ if ($s) $s .= '||';
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= "extract(year from $col)";
+ break;
+ case 'M':
+ case 'm':
+ $s .= "extract(month from $col)";
+ break;
+ case 'W':
+ case 'w':
+ // The more accurate way of doing this is with a stored procedure
+ // See http://wiki.firebirdsql.org/wiki/index.php?page=DATE+Handling+Functions for details
+ $s .= "((extract(yearday from $col) - extract(weekday from $col - 1) + 7) / 7)";
+ break;
+ case 'Q':
+ case 'q':
+ $s .= "cast(((extract(month from $col)+2) / 3) as integer)";
+ break;
+ case 'D':
+ case 'd':
+ $s .= "(extract(day from $col))";
+ break;
+ case 'H':
+ case 'h':
+ $s .= "(extract(hour from $col))";
+ break;
+ case 'I':
+ case 'i':
+ $s .= "(extract(minute from $col))";
+ break;
+ case 'S':
+ case 's':
+ $s .= "CAST((extract(second from $col)) AS INTEGER)";
+ break;
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $this->qstr($ch);
+ break;
+ }
+ }
+ return $s;
+ }
+
// Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars!
// SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
// SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
- function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0)
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0)
{
$nrows = (integer) $nrows;
$offset = (integer) $offset;
@@ -58,16 +765,173 @@ class ADODB_firebird extends ADODB_ibase {
return $rs;
}
+}
-};
-
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
-class ADORecordSet_firebird extends ADORecordSet_ibase {
+class ADORecordset_firebird extends ADORecordSet
+{
var $databaseType = "firebird";
+ var $bind=false;
+ var $_cacheType;
function __construct($id,$mode=false)
{
- parent::__construct($id,$mode);
+ global $ADODB_FETCH_MODE;
+
+ $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode;
+ parent::__construct($id);
+ }
+
+ /**
+ * Get column information in the Recordset object.
+ * fetchField() can be used in order to obtain information about fields in
+ * a certain query result. If the field offset isn't specified, the next
+ * field that wasn't yet retrieved by fetchField() is retrieved.
+ * @return object containing field information.
+ */
+ function FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $ibf = fbird_field_info($this->_queryID,$fieldOffset);
+
+ $name = empty($ibf['alias']) ? $ibf['name'] : $ibf['alias'];
+
+ 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()
+ {
+ $this->_numOfRows = -1;
+ $this->_numOfFields = @fbird_num_fields($this->_queryID);
+
+ // cache types for blob decode check
+ for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
+ $f1 = $this->FetchField($i);
+ $this->_cacheType[] = $f1->type;
+ }
+ }
+
+ function _seek($row)
+ {
+ return false;
+ }
+
+ function _fetch()
+ {
+ $f = @fbird_fetch_row($this->_queryID);
+ if ($f === false) {
+ $this->fields = false;
+ return false;
+ }
+ // OPN stuff start - optimized
+ // fix missing nulls and decode blobs automatically
+
+ global $ADODB_ANSI_PADDING_OFF;
+ //$ADODB_ANSI_PADDING_OFF=1;
+ $rtrim = !empty($ADODB_ANSI_PADDING_OFF);
+
+ for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
+ if ($this->_cacheType[$i]=="BLOB") {
+ if (isset($f[$i])) {
+ $f[$i] = $this->connection->_BlobDecode($f[$i]);
+ } else {
+ $f[$i] = null;
+ }
+ } else {
+ if (!isset($f[$i])) {
+ $f[$i] = null;
+ } else if ($rtrim && is_string($f[$i])) {
+ $f[$i] = rtrim($f[$i]);
+ }
+ }
+ }
+ // OPN stuff end
+
+ $this->fields = $f;
+ if ($this->fetchMode == ADODB_FETCH_ASSOC) {
+ $this->fields = $this->GetRowAssoc();
+ } else if ($this->fetchMode == ADODB_FETCH_BOTH) {
+ $this->fields = array_merge($this->fields,$this->GetRowAssoc());
+ }
+ return true;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+
}
+
+
+ function _close()
+ {
+ return @fbird_free_result($this->_queryID);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'CHAR':
+ return 'C';
+
+ case 'TEXT':
+ case 'VARCHAR':
+ case 'VARYING':
+ if ($len <= $this->blobSize) return 'C';
+ return 'X';
+ case 'BLOB':
+ return 'B';
+
+ case 'TIMESTAMP':
+ case 'DATE': return 'D';
+ case 'TIME': return 'T';
+ //case 'T': return 'T';
+
+ //case 'L': return 'L';
+ case 'INT':
+ case 'SHORT':
+ case 'INTEGER': return 'I';
+ default: return ADODB_DEFAULT_METATYPE;
+ }
+ }
+
}
diff --git a/drivers/adodb-ibase.inc.php b/drivers/adodb-ibase.inc.php
index 89862203..3a079811 100644
--- a/drivers/adodb-ibase.inc.php
+++ b/drivers/adodb-ibase.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -911,7 +911,7 @@ class ADORecordset_ibase extends ADORecordSet
case 'INT':
case 'SHORT':
case 'INTEGER': return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
diff --git a/drivers/adodb-informix.inc.php b/drivers/adodb-informix.inc.php
index f61ed632..399f642d 100644
--- a/drivers/adodb-informix.inc.php
+++ b/drivers/adodb-informix.inc.php
@@ -1,6 +1,6 @@
<?php
/**
-* @version v5.20.10 08-Mar-2018
+* @version v5.21.0-dev ??-???-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
@@ -33,9 +33,4 @@ class ADODB_informix extends ADODB_informix72 {
class ADORecordset_informix extends ADORecordset_informix72 {
var $databaseType = "informix";
-
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-informix72.inc.php b/drivers/adodb-informix72.inc.php
index e0b75c97..8b67dad6 100644
--- a/drivers/adodb-informix72.inc.php
+++ b/drivers/adodb-informix72.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-ldap.inc.php b/drivers/adodb-ldap.inc.php
index 95387f20..a54bb09a 100644
--- a/drivers/adodb-ldap.inc.php
+++ b/drivers/adodb-ldap.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -45,10 +45,6 @@ class ADODB_ldap extends ADOConnection {
# error on binding, eg. "Binding: invalid credentials"
var $_bind_errmsg = "Binding: %s";
- function __construct()
- {
- }
-
// returns true or false
function _connect( $host, $username, $password, $ldapbase)
@@ -331,7 +327,7 @@ class ADORecordSet_ldap extends ADORecordSet{
/*
Return whole recordset as a multi-dimensional associative array
*/
- function GetAssoc($force_array = false, $first2cols = false)
+ function GetAssoc($force_array = false, $first2cols = false, $fetchMode = -1)
{
$records = $this->_numOfRows;
$results = array();
diff --git a/drivers/adodb-mssql.inc.php b/drivers/adodb-mssql.inc.php
index da3791c1..db99635b 100644
--- a/drivers/adodb-mssql.inc.php
+++ b/drivers/adodb-mssql.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -155,9 +155,9 @@ class ADODB_mssql extends ADOConnection {
// the same scope. A scope is a module -- a stored procedure, trigger,
// function, or batch. Thus, two statements are in the same scope if
// they are in the same stored procedure, function, or batch.
- if ($this->lastInsID !== false) {
- return $this->lastInsID; // InsID from sp_executesql call
- } else {
+ if ($this->lastInsID !== false) {
+ return $this->lastInsID; // InsID from sp_executesql call
+ } else {
return $this->GetOne($this->identitySQL);
}
}
@@ -177,22 +177,22 @@ class ADODB_mssql extends ADOConnection {
*/
function qstr($s,$magic_quotes=false)
{
- if (!$magic_quotes) {
- return "'".str_replace("'",$this->replaceQuote,$s)."'";
+ if (!$magic_quotes) {
+ return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
- // undo magic quotes for " unless sybase is on
- $sybase = ini_get('magic_quotes_sybase');
- if (!$sybase) {
- $s = str_replace('\\"','"',$s);
- if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
- return "'$s'";
- else {// change \' to '' for sybase/mssql
- $s = str_replace('\\\\','\\',$s);
- return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
- }
- } else {
- return "'".$s."'";
+ // undo magic quotes for " unless sybase is on
+ $sybase = ini_get('magic_quotes_sybase');
+ if (!$sybase) {
+ $s = str_replace('\\"','"',$s);
+ if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
+ return "'$s'";
+ else {// change \' to '' for sybase/mssql
+ $s = str_replace('\\\\','\\',$s);
+ return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
+ }
+ } else {
+ return "'".$s."'";
}
}
// moodle change end - see readme_moodle.txt
@@ -309,7 +309,9 @@ class ADODB_mssql extends ADOConnection {
case 'A':
$s .= "substring(convert(char(19),$col,0),18,2)";
break;
-
+ case 'l':
+ $s .= "datename(dw,$col)";
+ break;
default:
if ($ch == '\\') {
$i++;
@@ -327,8 +329,8 @@ class ADODB_mssql extends ADOConnection {
{
if ($this->transOff) return true;
$this->transCnt += 1;
- $ok = $this->Execute('BEGIN TRAN');
- return $ok;
+ $ok = $this->Execute('BEGIN TRAN');
+ return $ok;
}
function CommitTrans($ok=true)
@@ -451,29 +453,29 @@ class ADODB_mssql extends ADOConnection {
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== FALSE) {
- $savem = $this->SetFetchMode(FALSE);
- }
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
- $rs = $this->Execute($sql);
- if (isset($savem)) {
- $this->SetFetchMode($savem);
- }
- $ADODB_FETCH_MODE = $save;
+ $rs = $this->Execute($sql);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
- if (!is_object($rs)) {
- return FALSE;
- }
+ if (!is_object($rs)) {
+ return FALSE;
+ }
$indexes = array();
while ($row = $rs->FetchRow()) {
if ($primary && !$row[5]) continue;
- $indexes[$row[0]]['unique'] = $row[6];
- $indexes[$row[0]]['columns'][] = $row[1];
- }
- return $indexes;
+ $indexes[$row[0]]['unique'] = $row[6];
+ $indexes[$row[0]]['columns'][] = $row[1];
+ }
+ return $indexes;
}
function MetaForeignKeys($table, $owner=false, $upper=false)
@@ -488,7 +490,7 @@ class ADODB_mssql extends ADOConnection {
"select object_name(constid) as constraint_name,
col_name(fkeyid, fkey) as column_name,
object_name(rkeyid) as referenced_table_name,
- col_name(rkeyid, rkey) as referenced_column_name
+ col_name(rkeyid, rkey) as referenced_column_name
from sysforeignkeys
where upper(object_name(fkeyid)) = $table
order by constraint_name, referenced_table_name, keyno";
@@ -519,22 +521,24 @@ order by constraint_name, referenced_table_name, keyno";
function MetaDatabases()
{
if(@mssql_select_db("master")) {
- $qry=$this->metaDatabasesSQL;
- if($rs=@mssql_query($qry,$this->_connectionID)){
- $tmpAr=$ar=array();
- while($tmpAr=@mssql_fetch_row($rs))
- $ar[]=$tmpAr[0];
- @mssql_select_db($this->database);
- if(sizeof($ar))
- return($ar);
- else
- return(false);
- } else {
- @mssql_select_db($this->database);
- return(false);
- }
- }
- return(false);
+ $qry = $this->metaDatabasesSQL;
+ if($rs = @mssql_query($qry,$this->_connectionID)) {
+ $tmpAr = $ar = array();
+ while($tmpAr = @mssql_fetch_row($rs)) {
+ $ar[]=$tmpAr[0];
+ }
+ @mssql_select_db($this->database);
+ if(sizeof($ar)) {
+ return($ar);
+ } else {
+ return(false);
+ }
+ } else {
+ @mssql_select_db($this->database);
+ return(false);
+ }
+ }
+ return(false);
}
// "Stein-Aksel Basma" <basma@accelero.no>
@@ -607,14 +611,18 @@ order by constraint_name, referenced_table_name, keyno";
if (!$id) return false;
$arr = mssql_fetch_array($id);
@mssql_free_result($id);
- if (is_array($arr)) return $arr[0];
- else return -1;
+ if (is_array($arr)) {
+ return $arr[0];
+ } else {
+ return -1;
+ }
}
// returns true or false, newconnect supported since php 5.1.0.
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$newconnect=false)
{
if (!function_exists('mssql_pconnect')) return null;
+ if (!empty($this->port)) $argHostname .= ":".$this->port;
$this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword,$newconnect);
if ($this->_connectionID === false) return false;
if ($argDatabasename) return $this->SelectDB($argDatabasename);
@@ -626,6 +634,7 @@ order by constraint_name, referenced_table_name, keyno";
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('mssql_pconnect')) return null;
+ if (!empty($this->port)) $argHostname .= ":".$this->port;
$this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) return false;
@@ -639,9 +648,9 @@ order by constraint_name, referenced_table_name, keyno";
}
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
- {
+ {
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
- }
+ }
function Prepare($sql)
{
@@ -666,21 +675,21 @@ order by constraint_name, referenced_table_name, keyno";
}
// returns concatenated string
- // MSSQL requires integers to be cast as strings
- // automatically cast every datatype to VARCHAR(255)
- // @author David Rogers (introspectshun)
- function Concat()
- {
- $s = "";
- $arr = func_get_args();
+ // MSSQL requires integers to be cast as strings
+ // automatically cast every datatype to VARCHAR(255)
+ // @author David Rogers (introspectshun)
+ function Concat()
+ {
+ $s = "";
+ $arr = func_get_args();
- // Split single record on commas, if possible
- if (sizeof($arr) == 1) {
- foreach ($arr as $arg) {
- $args = explode(',', $arg);
- }
- $arr = $args;
- }
+ // Split single record on commas, if possible
+ if (sizeof($arr) == 1) {
+ foreach ($arr as $arg) {
+ $args = explode(',', $arg);
+ }
+ $arr = $args;
+ }
array_walk(
$arr,
@@ -688,11 +697,11 @@ order by constraint_name, referenced_table_name, keyno";
$value = "CAST(" . $value . " AS VARCHAR(255))";
}
);
- $s = implode('+',$arr);
- if (sizeof($arr) > 0) return "$s";
+ $s = implode('+',$arr);
+ if (sizeof($arr) > 0) return "$s";
return '';
- }
+ }
/*
Usage:
@@ -780,11 +789,11 @@ order by constraint_name, referenced_table_name, keyno";
# bind input params with sp_executesql:
# see http://www.quest-pipelines.com/newsletter-v3/0402_F.htm
# works only with sql server 7 and newer
- $getIdentity = false;
- if (!is_array($sql) && preg_match('/^\\s*insert/i', $sql)) {
- $getIdentity = true;
- $sql .= (preg_match('/;\\s*$/i', $sql) ? ' ' : '; ') . $this->identitySQL;
- }
+ $getIdentity = false;
+ if (!is_array($sql) && preg_match('/^\\s*insert/i', $sql)) {
+ $getIdentity = true;
+ $sql .= (preg_match('/;\\s*$/i', $sql) ? ' ' : '; ') . $this->identitySQL;
+ }
if (!is_array($sql)) $sql = $this->Prepare($sql);
$params = '';
$decl = '';
@@ -824,20 +833,20 @@ order by constraint_name, referenced_table_name, keyno";
$decl = $this->qstr($decl);
if ($this->debug) ADOConnection::outp("<font size=-1>sp_executesql N{$sql[1]},N$decl,$params</font>");
$rez = mssql_query("sp_executesql N{$sql[1]},N$decl,$params", $this->_connectionID);
- if ($getIdentity) {
- $arr = @mssql_fetch_row($rez);
- $this->lastInsID = isset($arr[0]) ? $arr[0] : false;
- @mssql_data_seek($rez, 0);
- }
+ if ($getIdentity) {
+ $arr = @mssql_fetch_row($rez);
+ $this->lastInsID = isset($arr[0]) ? $arr[0] : false;
+ @mssql_data_seek($rez, 0);
+ }
} else if (is_array($sql)) {
# PrepareSP()
$rez = mssql_execute($sql[1]);
- $this->lastInsID = false;
+ $this->lastInsID = false;
} else {
$rez = mssql_query($sql,$this->_connectionID);
- $this->lastInsID = false;
+ $this->lastInsID = false;
}
return $rez;
}
@@ -845,8 +854,12 @@ order by constraint_name, referenced_table_name, keyno";
// returns true or false
function _close()
{
- if ($this->transCnt) $this->RollbackTrans();
- $rez = @mssql_close($this->_connectionID);
+ if ($this->transCnt) {
+ $this->RollbackTrans();
+ }
+ if($this->_connectionID) {
+ $rez = mssql_close($this->_connectionID);
+ }
$this->_connectionID = false;
return $rez;
}
@@ -861,10 +874,36 @@ order by constraint_name, referenced_table_name, keyno";
{
return ADORecordSet_array_mssql::UnixTimeStamp($v);
}
+
+ /**
+ * Returns a substring of a varchar type field
+ *
+ * The SQL server version varies because the length is mandatory, so
+ * we append a reasonable string length
+ *
+ * @param string $fld The field to sub-string
+ * @param int $start The start point
+ * @param int $length An optional length
+ *
+ * @return The SQL text
+ */
+ function substr($fld,$start,$length=0)
+ {
+ if ($length == 0)
+ /*
+ * The length available to varchar is 2GB, but that makes no
+ * sense in a substring, so I'm going to arbitrarily limit
+ * the length to 1K, but you could change it if you want
+ */
+ $length = 1024;
+
+ $text = "SUBSTRING($fld,$start,$length)";
+ return $text;
+ }
}
/*--------------------------------------------------------------------------------------
- Class Name: Recordset
+ Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordset_mssql extends ADORecordSet {
@@ -885,7 +924,7 @@ class ADORecordset_mssql extends ADORecordSet {
}
$this->fetchMode = $mode;
- return parent::__construct($id,$mode);
+ return parent::__construct($id);
}
@@ -921,7 +960,7 @@ class ADORecordset_mssql extends ADORecordSet {
}
}
- return $this->fields[$this->bind[strtoupper($colname)]];
+ return $this->fields[$this->bind[strtoupper($colname)]];
}
/* Returns: an object containing field information.
@@ -961,7 +1000,7 @@ class ADORecordset_mssql extends ADORecordSet {
}
else {
if ($this->hasFetchAssoc) {// only for PHP 4.2.0 or later
- $this->fields = @mssql_fetch_assoc($this->_queryID);
+ $this->fields = @mssql_fetch_assoc($this->_queryID);
} else {
$flds = @mssql_fetch_array($this->_queryID);
if (is_array($flds)) {
@@ -1077,16 +1116,36 @@ class ADORecordset_mssql extends ADORecordSet {
return ADORecordSet_array_mssql::UnixTimeStamp($v);
}
+ /**
+ * Returns the maximum size of a MetaType C field. Because of the
+ * database design, SQL Server places no limits on the size of data inserted
+ * Although the actual limit is 2^31-1 bytes.
+ *
+ * @return int
+ */
+ function charMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType X field. Because of the
+ * database design, SQL Server places no limits on the size of data inserted
+ * Although the actual limit is 2^31-1 bytes.
+ *
+ * @return int
+ */
+ function textMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
}
class ADORecordSet_array_mssql extends ADORecordSet_array {
- function __construct($id=-1,$mode=false)
- {
- parent::__construct($id,$mode);
- }
- // mssql uses a default date like Dec 30 2000 12:00AM
+ // mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v)
{
@@ -1126,8 +1185,8 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
global $ADODB_mssql_mths,$ADODB_mssql_date_order;
//Dec 30 2000 12:00AM
- if ($ADODB_mssql_date_order == 'dmy') {
- if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
+ if ($ADODB_mssql_date_order == 'dmy') {
+ if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
@@ -1163,11 +1222,11 @@ class ADORecordSet_array_mssql extends ADORecordSet_array {
/*
Code Example 1:
-select object_name(constid) as constraint_name,
- object_name(fkeyid) as table_name,
- col_name(fkeyid, fkey) as column_name,
+select object_name(constid) as constraint_name,
+ object_name(fkeyid) as table_name,
+ col_name(fkeyid, fkey) as column_name,
object_name(rkeyid) as referenced_table_name,
- col_name(rkeyid, rkey) as referenced_column_name
+ col_name(rkeyid, rkey) as referenced_column_name
from sysforeignkeys
where object_name(fkeyid) = x
order by constraint_name, table_name, referenced_table_name, keyno
diff --git a/drivers/adodb-mssql_n.inc.php b/drivers/adodb-mssql_n.inc.php
index 2bbac5b2..d1768571 100644
--- a/drivers/adodb-mssql_n.inc.php
+++ b/drivers/adodb-mssql_n.inc.php
@@ -65,12 +65,12 @@ class ADODB_mssql_n extends ADODB_mssql {
* and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add
* the "N" notation when working against MSSQL.
*
- * The orginal note indicated that this hack should only be used if ALL the char-based columns
+ * 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
*
@@ -79,22 +79,22 @@ class ADODB_mssql_n extends ADODB_mssql {
function _appendN($inboundData) {
$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))
{
/*
@@ -105,7 +105,7 @@ class ADODB_mssql_n extends ADODB_mssql {
continue;
}
-
+
if (strpos($inboundValue, SINGLEQUOTE) === false)
{
/*
@@ -120,11 +120,11 @@ class ADODB_mssql_n extends ADODB_mssql {
* 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 ((substr_count($inboundValue, SINGLEQUOTE) & 1))
{
if ($this->debug)
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
-
+
break;
}
@@ -135,9 +135,9 @@ class ADODB_mssql_n extends ADODB_mssql {
$regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
if (preg_match($regexp, $inboundValue))
{
- if ($this->debug)
+ if ($this->debug)
ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
-
+
break;
}
@@ -147,16 +147,16 @@ class ADODB_mssql_n extends ADODB_mssql {
$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);
-
+
}
/*
@@ -165,13 +165,13 @@ class ADODB_mssql_n extends ADODB_mssql {
$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);
}
@@ -184,11 +184,11 @@ class ADODB_mssql_n extends ADODB_mssql {
foreach ($literals as $key=>$value) {
if (!is_numeric(trim($value, SINGLEQUOTE)))
/*
- * Non numeric string, prepend our dear N, whilst
+ * Non numeric string, prepend our dear N, whilst
* Trimming potentially existing previous "N"
*/
- $literals[$key] = 'N' . trim($value, 'N');
-
+ $literals[$key] = 'N' . trim($value, 'N');
+
}
}
@@ -197,7 +197,7 @@ class ADODB_mssql_n extends ADODB_mssql {
*/
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
@@ -210,40 +210,36 @@ class ADODB_mssql_n extends ADODB_mssql {
*/
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;
}
-
+
/*
* 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 __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-mssqlnative.inc.php b/drivers/adodb-mssqlnative.inc.php
index 7ee4ed50..7551bdb9 100644
--- a/drivers/adodb-mssqlnative.inc.php
+++ b/drivers/adodb-mssqlnative.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -55,11 +55,11 @@ if (!function_exists('sqlsrv_log_set_subsystems')) {
// MORE LOCALIZATION INFO
// ----------------------
// To configure datetime, look for and modify sqlcommn.loc,
-// typically found in c:\mssql\install
+// typically found in c:\mssql\install
// Also read :
-// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
+// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
// Alternatively use:
-// CONVERT(char(12),datecol,120)
+// CONVERT(char(12),datecol,120)
//
// Also if your month is showing as month-1,
// e.g. Jan 13, 2002 is showing as 13/0/2002, then see
@@ -73,7 +73,7 @@ if (ADODB_PHPVER >= 0x4300) {
// docs say 4.2.0, but testing shows only since 4.3.0 does it work!
ini_set('mssql.datetimeconvert',0);
} else {
- global $ADODB_mssql_mths; // array, months must be upper-case
+ global $ADODB_mssql_mths; // array, months must be upper-case
$ADODB_mssql_date_order = 'mdy';
$ADODB_mssql_mths = array(
'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
@@ -124,8 +124,10 @@ class ADODB_mssqlnative extends ADOConnection {
var $uniqueOrderBy = true;
var $_bindInputArray = true;
var $_dropSeqSQL = "drop table %s";
- var $connectionInfo = array();
+
+ var $connectionInfo = array('ReturnDatesAsStrings'=>true);
var $cachedSchemaFlush = false;
+
var $sequences = false;
var $mssql_version = '';
@@ -163,7 +165,7 @@ class ADODB_mssqlnative extends ADOConnection {
}
function ServerInfo() {
- global $ADODB_FETCH_MODE;
+ global $ADODB_FETCH_MODE;
static $arr = false;
if (is_array($arr))
return $arr;
@@ -189,11 +191,9 @@ class ADODB_mssqlnative extends ADOConnection {
function _insertid()
{
- // SCOPE_IDENTITY()
- // Returns the last IDENTITY value inserted into an IDENTITY column in
- // the same scope. A scope is a module -- a stored procedure, trigger,
- // function, or batch. Thus, two statements are in the same scope if
- // they are in the same stored procedure, function, or batch.
+ $rez = sqlsrv_query($this->_connectionID,$this->identitySQL);
+ sqlsrv_fetch($rez);
+ $this->lastInsertID = sqlsrv_get_field($rez, 0);
return $this->lastInsertID;
}
@@ -204,8 +204,6 @@ class ADODB_mssqlnative extends ADOConnection {
}
function GenID($seq='adodbseq',$start=1) {
- if (!$this->mssql_version)
- $this->ServerVersion();
switch($this->mssql_version){
case 9:
case 10:
@@ -219,9 +217,6 @@ class ADODB_mssqlnative extends ADOConnection {
function CreateSequence($seq='adodbseq',$start=1)
{
- if (!$this->mssql_version)
- $this->ServerVersion();
-
switch($this->mssql_version){
case 9:
case 10:
@@ -231,7 +226,6 @@ class ADODB_mssqlnative extends ADOConnection {
return $this->CreateSequence2012($seq, $start);
break;
}
-
}
/**
@@ -365,7 +359,9 @@ class ADODB_mssqlnative extends ADOConnection {
case 'A':
$s .= "substring(convert(char(19),$col,0),18,2)";
break;
-
+ case 'l':
+ $s .= "datename(dw,$col)";
+ break;
default:
if ($ch == '\\') {
$i++;
@@ -397,6 +393,7 @@ class ADODB_mssqlnative extends ADOConnection {
sqlsrv_commit($this->_connectionID);
return true;
}
+
function RollbackTrans()
{
if ($this->transOff) return true;
@@ -473,22 +470,30 @@ class ADODB_mssqlnative extends ADOConnection {
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if (!function_exists('sqlsrv_connect')) return null;
- $connectionInfo = $this->connectionInfo;
- $connectionInfo["Database"]=$argDatabasename;
- $connectionInfo["UID"]=$argUsername;
- $connectionInfo["PWD"]=$argPassword;
-
- foreach ($this->connectionParameters as $parameter=>$value)
- $connectionInfo[$parameter] = $value;
-
+
+ $connectionInfo = $this->connectionInfo;
+ $connectionInfo["Database"] = $argDatabasename;
+ $connectionInfo["UID"] = $argUsername;
+ $connectionInfo["PWD"] = $argPassword;
+
+ /*
+ * Now merge in the passed connection parameters setting
+ */
+ foreach ($this->connectionParameters as $options)
+ {
+ foreach($options 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->_connectionID = sqlsrv_connect($argHostname,$connectionInfo)))
+ {
if ($this->debug) ADOConnection::outp( "<hr><b>errors</b>: ".print_r( sqlsrv_errors(), true));
return false;
}
- //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>");
+
+ $this->ServerVersion();
+
return true;
}
@@ -502,10 +507,6 @@ class ADODB_mssqlnative extends ADOConnection {
function Prepare($sql)
{
return $sql; // prepare does not work properly with bind parameters as bind parameters are managed by sqlsrv_prepare!
-
- $stmt = sqlsrv_prepare( $this->_connectionID, $sql);
- if (!$stmt) return $sql;
- return array($sql,$stmt);
}
// returns concatenated string
@@ -565,7 +566,8 @@ class ADODB_mssqlnative extends ADOConnection {
{
$this->_errorMsg = false;
- if (is_array($sql)) $sql = $sql[1];
+ if (is_array($sql))
+ $sql = $sql[1];
$insert = false;
// handle native driver flaw for retrieving the last insert ID
@@ -573,7 +575,14 @@ class ADODB_mssqlnative extends ADOConnection {
$insert = true;
$sql .= '; '.$this->identitySQL; // select scope_identity()
}
- if($inputarr) {
+ if($inputarr)
+ {
+ /*
+ * Ensure that the input array is numeric, as required by
+ * sqlsrv_query. If param() was used to create portable binds
+ * then the array might be associative
+ */
+ $inputarr = array_values($inputarr);
$rez = sqlsrv_query($this->_connectionID, $sql, $inputarr);
} else {
$rez = sqlsrv_query($this->_connectionID,$sql);
@@ -581,23 +590,21 @@ class ADODB_mssqlnative extends ADOConnection {
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) {
+ if(!$rez)
$rez = false;
- } else if ($insert) {
- // retrieve the last insert ID (where applicable)
- while ( sqlsrv_next_result($rez) ) {
- sqlsrv_fetch($rez);
- $this->lastInsertID = sqlsrv_get_field($rez, 0);
- }
- }
+
return $rez;
}
// returns true or false
function _close()
{
- if ($this->transCnt) $this->RollbackTrans();
- $rez = @sqlsrv_close($this->_connectionID);
+ if ($this->transCnt) {
+ $this->RollbackTrans();
+ }
+ if($this->_connectionID) {
+ $rez = sqlsrv_close($this->_connectionID);
+ }
$this->_connectionID = false;
return $rez;
}
@@ -670,7 +677,7 @@ class ADODB_mssqlnative extends ADOConnection {
where upper(object_name(fkeyid)) = $table
order by constraint_name, referenced_table_name, keyno";
- $constraints =& $this->GetArray($sql);
+ $constraints = $this->GetArray($sql);
$ADODB_FETCH_MODE = $save;
@@ -752,7 +759,9 @@ class ADODB_mssqlnative extends ADOConnection {
}
function MetaColumns($table, $upper=true, $schema=false){
- # start adg
+ /*
+ * A simple caching mechanism, to be replaced in ADOdb V6
+ */
static $cached_columns = array();
if ($this->cachedSchemaFlush)
$cached_columns = array();
@@ -760,10 +769,7 @@ class ADODB_mssqlnative extends ADOConnection {
if (array_key_exists($table,$cached_columns)){
return $cached_columns[$table];
}
- # end adg
- if (!$this->mssql_version)
- $this->ServerVersion();
$this->_findschema($table,$schema);
if ($schema) {
@@ -797,7 +803,7 @@ class ADODB_mssqlnative extends ADOConnection {
$fld->type = $rs->fields[1];
$fld->max_length = $rs->fields[2];
$fld->precision = $rs->fields[3];
- $fld->scale = $rs->fields[4];
+ $fld->scale = $rs->fields[4];
$fld->not_null =!$rs->fields[5];
$fld->has_default = $rs->fields[6];
$fld->xtype = $rs->fields[7];
@@ -808,7 +814,7 @@ class ADODB_mssqlnative extends ADOConnection {
$fld->type = $rs->fields['type'];
$fld->max_length = $rs->fields['length'];
$fld->precision = $rs->fields['precision'];
- $fld->scale = $rs->fields['scale'];
+ $fld->scale = $rs->fields['scale'];
$fld->not_null =!$rs->fields['nullable'];
$fld->has_default = $rs->fields['default_value'];
$fld->xtype = $rs->fields['xtype'];
@@ -825,16 +831,64 @@ class ADODB_mssqlnative extends ADOConnection {
}
$rs->Close();
- # start adg
$cached_columns[$table] = $retarr;
- # end adg
+
return $retarr;
}
+ /**
+ * Returns a substring of a varchar type field
+ *
+ * The SQL server version varies because the length is mandatory, so
+ * we append a reasonable string length
+ *
+ * @param string $fld The field to sub-string
+ * @param int $start The start point
+ * @param int $length An optional length
+ *
+ * @return The SQL text
+ */
+ function substr($fld,$start,$length=0)
+ {
+ if ($length == 0)
+ /*
+ * The length available to varchar is 2GB, but that makes no
+ * sense in a substring, so I'm going to arbitrarily limit
+ * the length to 1K, but you could change it if you want
+ */
+ $length = 1024;
+
+ $text = "SUBSTRING($fld,$start,$length)";
+ return $text;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType C field. Because of the
+ * database design, SQL Server places no limits on the size of data inserted
+ * Although the actual limit is 2^31-1 bytes.
+ *
+ * @return int
+ */
+ function charMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType X field. Because of the
+ * database design, SQL Server places no limits on the size of data inserted
+ * Although the actual limit is 2^31-1 bytes.
+ *
+ * @return int
+ */
+ function textMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
}
/*--------------------------------------------------------------------------------------
- Class Name: Recordset
+ Class Name: Recordset
--------------------------------------------------------------------------------------*/
class ADORecordset_mssqlnative extends ADORecordSet {
@@ -844,6 +898,67 @@ class ADORecordset_mssqlnative extends ADORecordSet {
var $fieldOffset = 0;
// _mths works only in non-localised system
+ /*
+ * Holds a cached version of the metadata
+ */
+ private $fieldObjects = false;
+
+ /*
+ * Flags if we have retrieved the metadata
+ */
+ private $fieldObjectsRetrieved = false;
+
+ /*
+ * Cross-reference the objects by name for easy access
+ */
+ private $fieldObjectsIndex = array();
+
+
+ /*
+ * Cross references the dateTime objects for faster decoding
+ */
+ private $dateTimeObjects = array();
+
+ /*
+ * flags that we have dateTimeObjects to handle
+ */
+ private $hasDateTimeObjects = false;
+
+ /*
+ * This is cross reference between how the types are stored
+ * in SQL Server and their english-language description
+ */
+ private $_typeConversion = array(
+ -155 => 'datetimeoffset',
+ -154 => 'time',
+ -152 => 'xml',
+ -151 => 'udt',
+ -11 => 'uniqueidentifier',
+ -10 => 'ntext',
+ -9 => 'nvarchar',
+ -8 => 'nchar',
+ -7 => 'bit',
+ -6 => 'tinyint',
+ -5 => 'bigint',
+ -4 => 'image',
+ -3 => 'varbinary',
+ -2 => 'timestamp',
+ -1 => 'text',
+ 1 => 'char',
+ 2 => 'numeric',
+ 3 => 'decimal',
+ 4 => 'int',
+ 5 => 'smallint',
+ 6 => 'float',
+ 7 => 'real',
+ 12 => 'varchar',
+ 91 => 'date',
+ 93 => 'datetime'
+ );
+
+
+
+
function __construct($id,$mode=false)
{
if ($mode === false) {
@@ -852,29 +967,19 @@ class ADORecordset_mssqlnative extends ADORecordSet {
}
$this->fetchMode = $mode;
- return parent::__construct($id,$mode);
+ return parent::__construct($id);
}
function _initrs()
{
- global $ADODB_COUNTRECS;
- # 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."
- 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) ADOConnection::outp("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}");
/*
- * Copy the oracle method and cache the metadata at init time
+ * Cache the metadata right now
*/
- if ($this->_numOfFields>0) {
- $this->_fieldobjs = array();
- $max = $this->_numOfFields;
- for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i);
- }
+ $this->_fetchField();
}
@@ -906,79 +1011,74 @@ class ADORecordset_mssqlnative extends ADORecordSet {
return $this->fields[$this->bind[strtoupper($colname)]];
}
- /* Returns: an object containing field information.
- Get column information in the Recordset object. fetchField() can be used in order to obtain information about
- fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
- fetchField() is retrieved.
- Designed By jcortinap#jc.com.mx
+ /**
+ * Returns: an object containing field information.
+ *
+ * Get column information in the Recordset object. fetchField()
+ * can be used in order to obtain information about fields in a
+ * certain query result. If the field offset isn't specified,
+ * the next field that wasn't yet retrieved by fetchField()
+ * is retrieved.
+ *
+ * $param int $fieldOffset (optional default=-1 for all
+ * @return mixed an ADOFieldObject, or array of objects
*/
- function _FetchField($fieldOffset = -1)
+ private function _fetchField($fieldOffset = -1)
{
- $_typeConversion = array(
- -155 => 'datetimeoffset',
- -154 => 'time',
- -152 => 'xml',
- -151 => 'udt',
- -11 => 'uniqueidentifier',
- -10 => 'ntext',
- -9 => 'nvarchar',
- -8 => 'nchar',
- -7 => 'bit',
- -6 => 'tinyint',
- -5 => 'bigint',
- -4 => 'image',
- -3 => 'varbinary',
- -2 => 'timestamp',
- -1 => 'text',
- 1 => 'char',
- 2 => 'numeric',
- 3 => 'decimal',
- 4 => 'int',
- 5 => 'smallint',
- 6 => 'float',
- 7 => 'real',
- 12 => 'varchar',
- 91 => 'date',
- 93 => 'datetime'
- );
-
- $fa = @sqlsrv_field_metadata($this->_queryID);
- if ($fieldOffset != -1) {
- $fa = $fa[$fieldOffset];
- }
- $false = false;
- if (empty($fa)) {
- $f = false;//PHP Notice: Only variable references should be returned by reference
- }
- else
- {
- // Convert to an object
- $fa = array_change_key_case($fa, CASE_LOWER);
- $fb = array();
- if ($fieldOffset != -1)
- {
- $fb = array(
- 'name' => $fa['name'],
- 'max_length' => $fa['size'],
- 'column_source' => $fa['name'],
- 'type' => $_typeConversion[$fa['type']]
- );
+ if ($this->fieldObjectsRetrieved){
+ if ($this->fieldObjects) {
+ /*
+ * Already got the information
+ */
+ if ($fieldOffset == -1)
+ return $this->fieldObjects;
+ else
+ return $this->fieldObjects[$fieldOffset];
}
else
- {
- foreach ($fa as $key => $value)
- {
- $fb[] = array(
- 'name' => $value['name'],
- 'max_length' => $value['size'],
- 'column_source' => $value['name'],
- 'type' => $_typeConversion[$value['type']]
- );
- }
- }
- $f = (object) $fb;
+ /*
+ * No metadata available
+ */
+ return false;
}
- return $f;
+
+ $this->fieldObjectsRetrieved = true;
+ /*
+ * Retrieve all metadata in one go. This is always returned as a
+ * numeric array.
+ */
+ $fieldMetaData = sqlsrv_field_metadata($this->_queryID);
+
+ if (!$fieldMetaData)
+ /*
+ * Not a statement that gives us metaData
+ */
+ return false;
+
+ $this->_numOfFields = count($fieldMetaData);
+ foreach ($fieldMetaData as $key=>$value)
+ {
+
+ $fld = new ADOFieldObject;
+ /*
+ * Caution - keys are case-sensitive, must respect
+ * casing of values
+ */
+
+ $fld->name = $value['Name'];
+ $fld->max_length = $value['Size'];
+ $fld->column_source = $value['Name'];
+ $fld->type = $this->_typeConversion[$value['Type']];
+
+ $this->fieldObjects[$key] = $fld;
+
+ $this->fieldObjectsIndex[$fld->name] = $key;
+
+ }
+ if ($fieldOffset == -1)
+ return $this->fieldObjects;
+
+ return $this->fieldObjects[$fieldOffset];
}
/*
@@ -986,12 +1086,16 @@ class ADORecordset_mssqlnative extends ADORecordSet {
* into the _fieldobjs array once, to save multiple calls to the
* sqlsrv_field_metadata function
*
+ * @param int $fieldOffset (optional)
+ *
+ * @return adoFieldObject
+ *
* @author KM Newnham
* @date 02/20/2013
*/
- function FetchField($fieldOffset = -1)
+ function fetchField($fieldOffset = -1)
{
- return $this->_fieldobjs[$fieldOffset];
+ return $this->fieldObjects[$fieldOffset];
}
function _seek($row)
@@ -1002,76 +1106,50 @@ class ADORecordset_mssqlnative extends ADORecordSet {
// speedup
function MoveNext()
{
- //# KMN # if ($this->connection->debug) ADOConnection::outp("movenext()");
- //# KMN # if ($this->connection->debug) ADOConnection::outp("eof (beginning): ".$this->EOF);
- if ($this->EOF) return false;
+ if ($this->EOF)
+ return false;
$this->_currentRow++;
- // # KMN # if ($this->connection->debug) ADOConnection::outp("_currentRow: ".$this->_currentRow);
- if ($this->_fetch()) return true;
+ if ($this->_fetch())
+ return true;
$this->EOF = true;
- //# KMN # if ($this->connection->debug) ADOConnection::outp("eof (end): ".$this->EOF);
return false;
}
-
- // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
- // 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) ADOConnection::outp("_fetch()");
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
- if ($this->fetchMode & ADODB_FETCH_NUM) {
- //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: both");
+ if ($this->fetchMode & ADODB_FETCH_NUM)
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH);
- } else {
- //# KMN # if ($this->connection->debug) ADOConnection::outp("fetch mode: assoc");
+ else
$this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC);
- }
- if (is_array($this->fields)) {
- if (ADODB_ASSOC_CASE == 0) {
- foreach($this->fields as $k=>$v) {
- $this->fields[strtolower($k)] = $v;
- }
- } else if (ADODB_ASSOC_CASE == 1) {
- foreach($this->fields as $k=>$v) {
- $this->fields[strtoupper($k)] = $v;
- }
- }
- }
- } else {
- //# 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
- $arrFixed = array();
- foreach($this->fields as $key=>$value) {
- if(is_numeric($key)) {
- $arrFixed[$key-1] = $value;
- } else {
- $arrFixed[$key] = $value;
- }
- }
- //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)) {
- foreach($this->fields as $key=>$value) {
- if (is_object($value) && method_exists($value, 'format')) {//is DateTime object
- $this->fields[$key] = $value->format("Y-m-d\TH:i:s\Z");
- }
+ if (is_array($this->fields))
+ {
+
+ if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER)
+ $this->fields = array_change_key_case($this->fields,CASE_LOWER);
+ else if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_UPPER)
+ $this->fields = array_change_key_case($this->fields,CASE_UPPER);
+
}
}
- if($this->fields === null) $this->fields = false;
- # KMN # if ($this->connection->debug) ADOConnection::outp("<hr>after _fetch, fields: <pre>".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
+ else
+ $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC);
+
+ if (!$this->fields)
+ return false;
+
return $this->fields;
}
- /* close() only needs to be called if you are worried about using too much memory while your script
- is running. All associated result memory for the specified result identifier will automatically be freed. */
+ /**
+ * close() only needs to be called if you are worried about using too much
+ * memory while your script is running. All associated result memory for
+ * the specified result identifier will automatically be freed.
+ */
function _close()
{
if(is_object($this->_queryID)) {
@@ -1096,12 +1174,8 @@ class ADORecordset_mssqlnative extends ADORecordSet {
class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
- function __construct($id=-1,$mode=false)
- {
- parent::__construct($id,$mode);
- }
- // mssql uses a default date like Dec 30 2000 12:00AM
+ // mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v)
{
@@ -1141,8 +1215,8 @@ class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
global $ADODB_mssql_mths,$ADODB_mssql_date_order;
//Dec 30 2000 12:00AM
- if ($ADODB_mssql_date_order == 'dmy') {
- if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
+ if ($ADODB_mssql_date_order == 'dmy') {
+ if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
diff --git a/drivers/adodb-mssqlpo.inc.php b/drivers/adodb-mssqlpo.inc.php
index 8397faed..2075514a 100644
--- a/drivers/adodb-mssqlpo.inc.php
+++ b/drivers/adodb-mssqlpo.inc.php
@@ -1,6 +1,6 @@
<?php
/**
-* @version v5.20.10 08-Mar-2018
+* @version v5.21.0-dev ??-???-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
@@ -51,8 +51,4 @@ class ADODB_mssqlpo extends ADODB_mssql {
class ADORecordset_mssqlpo extends ADORecordset_mssql {
var $databaseType = "mssqlpo";
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-mysql.inc.php b/drivers/adodb-mysql.inc.php
index 732acff6..cd7e4998 100644
--- a/drivers/adodb-mysql.inc.php
+++ b/drivers/adodb-mysql.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -12,7 +12,7 @@
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 (phpeverywhere@macfreek.com)
@@ -51,12 +51,31 @@ 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 __construct()
- {
- if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
+ /**
+ * ADODB_mysql constructor.
+ */
+ public function __construct() {
+ if(version_compare(PHP_VERSION, '7.0.0', '>=')) {
+ $this->outp_throw(
+ 'mysql extension is not supported since PHP 7.0.0, use mysqli instead',
+ __METHOD__
+ );
+ die(1); // Stop execution even if not using Exceptions
+ } elseif(version_compare(PHP_VERSION, '5.5.0', '>=')) {
+ // If mysql extension is available just print a warning,
+ // otherwise die with an error message
+ if(function_exists('mysql_connect')) {
+ $this->outp('mysql extension is deprecated since PHP 5.5.0, consider using mysqli');
+ } else {
+ $this->outp_throw(
+ 'mysql extension is not available, use mysqli instead',
+ __METHOD__
+ );
+ die(1); // Stop execution even if not using Exceptions
+ }
+ }
}
-
// SetCharSet - switch the client encoding
function SetCharSet($charset_name)
{
@@ -796,8 +815,6 @@ class ADORecordSet_mysql extends ADORecordSet{
function MoveNext()
{
- //return adodb_movenext($this);
- //if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
$this->_updatefields();
$this->_currentRow += 1;
@@ -872,17 +889,13 @@ class ADORecordSet_mysql extends ADORecordSet{
if (!empty($fieldobj->primary_key)) return 'R';
else return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
}
class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID,$mode);
- }
function MoveNext()
{
diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php
index 617eccdf..b694b8e3 100644
--- a/drivers/adodb-mysqli.inc.php
+++ b/drivers/adodb-mysqli.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -12,7 +12,7 @@
and non-transactional table types. You can use this as a drop-in replacement for both
the mysql and mysqlt drivers. As of ADOdb Version 5.20.0, all other native MySQL drivers
are deprecated
-
+
Requires mysql client. Works on Windows and Unix.
21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl)
@@ -29,9 +29,6 @@ if (! defined("_ADODB_MYSQLI_LAYER")) {
if (! defined("MYSQLI_BINARY_FLAG")) define("MYSQLI_BINARY_FLAG", 128);
if (!defined('MYSQLI_READ_DEFAULT_GROUP')) define('MYSQLI_READ_DEFAULT_GROUP',1);
- // disable adodb extension - currently incompatible.
- global $ADODB_EXTENSION; $ADODB_EXTENSION = false;
-
class ADODB_mysqli extends ADOConnection {
var $databaseType = 'mysqli';
var $dataProvider = 'mysql';
@@ -63,11 +60,12 @@ class ADODB_mysqli extends ADOConnection {
var $arrayClass = 'ADORecordSet_array_mysqli';
var $multiQuery = false;
- function __construct()
- {
- // if(!extension_loaded("mysqli"))
- //trigger_error("You must have the mysqli extension installed.", E_USER_ERROR);
- }
+ /*
+ * Tells the insert_id method how to obtain the last value, depending on whether
+ * we are using a stored procedure or not
+ */
+ private $usePreparedStatement = false;
+ private $useLastInsertStatement = false;
function SetTransactionMode( $transaction_mode )
{
@@ -105,10 +103,20 @@ class ADODB_mysqli extends ADOConnection {
read connection options from the standard mysql configuration file
/etc/my.cnf - "Bastien Duclaux" <bduclaux#yahoo.com>
*/
+ $this->optionFlags = array();
foreach($this->optionFlags as $arr) {
mysqli_options($this->_connectionID,$arr[0],$arr[1]);
}
+ /*
+ * Now merge in the standard connection parameters setting
+ */
+ foreach ($this->connectionParameters as $options)
+ {
+ foreach($options as $k=>$v)
+ $ok = mysqli_options($this->_connectionID,$k,$v);
+ }
+
//http ://php.net/manual/en/mysqli.persistconns.php
if ($persist && PHP_VERSION > 5.2 && strncmp($argHostname,'p:',2) != 0) $argHostname = 'p:'.$argHostname;
@@ -254,10 +262,26 @@ class ADODB_mysqli extends ADOConnection {
function _insertid()
{
- $result = @mysqli_insert_id($this->_connectionID);
+ /*
+ * mysqli_insert_id does not return the last_insert_id
+ * if called after execution of a stored procedure
+ * so we execute this instead.
+ */
+ $result = false;
+ if ($this->useLastInsertStatement)
+ $result = ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
+ else
+ $result = @mysqli_insert_id($this->_connectionID);
+
if ($result == -1) {
- if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
+ if ($this->debug)
+ ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
}
+ /*
+ * reset prepared statement flags
+ */
+ $this->usePreparedStatement = false;
+ $this->useLastInsertStatement = false;
return $result;
}
@@ -575,17 +599,25 @@ class ADODB_mysqli 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;
+ global $ADODB_FETCH_MODE;
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC
+ || $this->fetchMode == ADODB_FETCH_ASSOC)
+ $associative = true;
+
+ $savem = $ADODB_FETCH_MODE;
+ $this->setFetchMode(ADODB_FETCH_ASSOC);
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];
+
+ $this->setFetchMode($savem);
+
+ $create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
$matches = array();
@@ -729,6 +761,14 @@ class ADODB_mysqli extends ADOConnection {
function Prepare($sql)
{
+ /*
+ * Flag the insert_id method to use the correct retrieval method
+ */
+ $this->usePreparedStatement = true;
+
+ /*
+ * Prepared statements are not yet handled correctly
+ */
return $sql;
$stmt = $this->_connectionID->prepare($sql);
if (!$stmt) {
@@ -763,11 +803,26 @@ class ADODB_mysqli extends ADOConnection {
else $a .= 'd';
}
+ /*
+ * set prepared statement flags
+ */
+ if ($this->usePreparedStatement)
+ $this->useLastInsertStatement = true;
+
$fnarr = array_merge( array($stmt,$a) , $inputarr);
$ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
$ret = mysqli_stmt_execute($stmt);
return $ret;
}
+ else
+ {
+ /*
+ * reset prepared statement flags, in case we set them
+ * previously and didn't use them
+ */
+ $this->usePreparedStatement = false;
+ $this->useLastInsertStatement = false;
+ }
/*
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
@@ -819,7 +874,9 @@ class ADODB_mysqli extends ADOConnection {
// returns true or false
function _close()
{
- @mysqli_close($this->_connectionID);
+ if($this->_connectionID) {
+ mysqli_close($this->_connectionID);
+ }
$this->_connectionID = false;
}
@@ -960,7 +1017,13 @@ class ADORecordSet_mysqli extends ADORecordSet{
// $o->blob = $o->flags & MYSQLI_BLOB_FLAG; /* not returned by MetaColumns */
$o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG;
- return $o;
+ /*
+ * Trivial method to cast class to ADOfieldObject
+ */
+ $a = new ADOFieldObject;
+ foreach (get_object_vars($o) as $key => $name)
+ $a->$key = $name;
+ return $a;
}
function GetRowAssoc($upper = ADODB_ASSOC_CASE)
@@ -1193,11 +1256,6 @@ class ADORecordSet_mysqli extends ADORecordSet{
class ADORecordSet_array_mysqli extends ADORecordSet_array {
- function __construct($id=-1,$mode=false)
- {
- parent::__construct($id,$mode);
- }
-
function MetaType($t, $len = -1, $fieldobj = false)
{
if (is_object($t)) {
diff --git a/drivers/adodb-mysqlpo.inc.php b/drivers/adodb-mysqlpo.inc.php
index 6e6bb4fe..cf430799 100644
--- a/drivers/adodb-mysqlpo.inc.php
+++ b/drivers/adodb-mysqlpo.inc.php
@@ -1,7 +1,7 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -11,8 +11,8 @@
MySQL code that supports transactions. For MySQL 3.23 or later.
Code from James Poon <jpoon88@yahoo.com>
-
- This driver extends the deprecated mysql driver, and was originally designed to be a
+
+ 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.
@@ -32,11 +32,6 @@ class ADODB_mysqlt extends ADODB_mysql {
var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly
- function __construct()
- {
- global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
- }
-
function BeginTrans()
{
if ($this->transOff) return true;
@@ -116,11 +111,6 @@ class ADORecordSet_mysqlt extends ADORecordSet_mysql{
class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID,$mode);
- }
-
function MoveNext()
{
return adodb_movenext($this);
diff --git a/drivers/adodb-mysqlt.inc.php b/drivers/adodb-mysqlt.inc.php
index c566463a..c627643e 100644
--- a/drivers/adodb-mysqlt.inc.php
+++ b/drivers/adodb-mysqlt.inc.php
@@ -1,7 +1,7 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -29,11 +29,6 @@ class ADODB_mysqlt extends ADODB_mysql {
var $hasTransactions = true;
var $autoRollback = true; // apparently mysql does not autorollback properly
- function __construct()
- {
- global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
- }
-
/* set transaction mode
SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
diff --git a/drivers/adodb-netezza.inc.php b/drivers/adodb-netezza.inc.php
index f56431a6..398472ac 100644
--- a/drivers/adodb-netezza.inc.php
+++ b/drivers/adodb-netezza.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
@@ -50,11 +50,6 @@ class ADODB_netezza extends ADODB_postgres64 {
// http://bugs.php.net/bug.php?id=25404
- function __construct()
- {
-
- }
-
function MetaColumns($table,$upper=true)
{
@@ -141,11 +136,6 @@ class ADORecordSet_netezza extends ADORecordSet_postgres64
var $databaseType = "netezza";
var $canSeek = true;
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID,$mode);
- }
-
// _initrs modified to disable blob handling
function _initrs()
{
diff --git a/drivers/adodb-oci8.inc.php b/drivers/adodb-oci8.inc.php
index 75593569..b9595d20 100644
--- a/drivers/adodb-oci8.inc.php
+++ b/drivers/adodb-oci8.inc.php
@@ -1,7 +1,7 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
@@ -106,9 +106,6 @@ END;
function __construct()
{
$this->_hasOciFetchStatement = ADODB_PHPVER >= 0x4200;
- if (defined('ADODB_EXTENSION')) {
- $this->rsPrefix .= 'ext_';
- }
}
/* function MetaColumns($table, $normalize=true) added by smondino@users.sourceforge.net*/
@@ -1745,7 +1742,8 @@ class ADORecordset_oci8 extends ADORecordSet {
oci_free_cursor($this->_refcursor);
$this->_refcursor = false;
}
- @oci_free_statement($this->_queryID);
+ if (is_resource($this->_queryID))
+ @oci_free_statement($this->_queryID);
$this->_queryID = false;
}
@@ -1802,16 +1800,12 @@ class ADORecordset_oci8 extends ADORecordSet {
return 'I';
default:
- return 'N';
+ return ADODB_DEFAULT_METATYPE;
}
}
}
class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 {
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID, $mode);
- }
function MoveNext()
{
diff --git a/drivers/adodb-oci805.inc.php b/drivers/adodb-oci805.inc.php
index e8ab2937..77c242d7 100644
--- a/drivers/adodb-oci805.inc.php
+++ b/drivers/adodb-oci805.inc.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version v5.20.10 08-Mar-2018
+ * @version v5.21.0-dev ??-???-2016
* @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
* @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
* Released under both BSD license and Lesser GPL library license.
@@ -48,8 +48,4 @@ class ADODB_oci805 extends ADODB_oci8 {
class ADORecordset_oci805 extends ADORecordset_oci8 {
var $databaseType = "oci805";
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-oci8po.inc.php b/drivers/adodb-oci8po.inc.php
index 0d8851da..e04e25b6 100644
--- a/drivers/adodb-oci8po.inc.php
+++ b/drivers/adodb-oci8po.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -33,7 +33,6 @@ class ADODB_oci8po extends ADODB_oci8 {
function __construct()
{
$this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
- # oci8po does not support adodb extension: adodb_movenext()
}
function Param($name,$type='C')
@@ -114,11 +113,6 @@ class ADORecordset_oci8po extends ADORecordset_oci8 {
var $databaseType = 'oci8po';
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID,$mode);
- }
-
function Fields($colname)
{
if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
diff --git a/drivers/adodb-oci8quercus.inc.php b/drivers/adodb-oci8quercus.inc.php
index 16d4661f..79e3d006 100644
--- a/drivers/adodb-oci8quercus.inc.php
+++ b/drivers/adodb-oci8quercus.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -28,10 +28,6 @@ class ADODB_oci8quercus extends ADODB_oci8 {
var $databaseType = 'oci8quercus';
var $dataProvider = 'oci8';
- function __construct()
- {
- }
-
}
/*--------------------------------------------------------------------------------------
@@ -42,11 +38,6 @@ class ADORecordset_oci8quercus extends ADORecordset_oci8 {
var $databaseType = 'oci8quercus';
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID,$mode);
- }
-
function _FetchField($fieldOffset = -1)
{
global $QUERCUS;
diff --git a/drivers/adodb-odbc.inc.php b/drivers/adodb-odbc.inc.php
index 4ab7a031..52b26307 100644
--- a/drivers/adodb-odbc.inc.php
+++ b/drivers/adodb-odbc.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -17,6 +17,18 @@ if (!defined('ADODB_DIR')) die();
define("_ADODB_ODBC_LAYER", 2 );
+/*
+ * These constants are used to set define MetaColumns() method's behavior.
+ * - METACOLUMNS_RETURNS_ACTUAL makes the driver return the actual type,
+ * like all other drivers do (default)
+ * - METACOLUMNS_RETURNS_META is provided for legacy compatibility (makes
+ * driver behave as it did prior to v5.21)
+ *
+ * @see $metaColumnsReturnType
+ */
+DEFINE('METACOLUMNS_RETURNS_ACTUAL', 0);
+DEFINE('METACOLUMNS_RETURNS_META', 1);
+
/*--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------*/
@@ -40,6 +52,11 @@ class ADODB_odbc extends ADOConnection {
var $_has_stupid_odbc_fetch_api_change = true;
var $_lastAffectedRows = 0;
var $uCaseTables = true; // for meta* functions, uppercase table names
+
+ /*
+ * Tells the metaColumns feature whether to return actual or meta type
+ */
+ public $metaColumnsReturnType = METACOLUMNS_RETURNS_ACTUAL;
function __construct()
{
@@ -461,7 +478,16 @@ See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/od
if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
$fld = new ADOFieldObject();
$fld->name = $rs->fields[3];
- $fld->type = $this->ODBCTypes($rs->fields[4]);
+ if ($this->metaColumnsReturnType == METACOLUMNS_RETURNS_META)
+ /*
+ * This is the broken, original value
+ */
+ $fld->type = $this->ODBCTypes($rs->fields[4]);
+ else
+ /*
+ * This is the correct new value
+ */
+ $fld->type = $rs->fields[4];
// ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
// access uses precision to store length for char/varchar
diff --git a/drivers/adodb-odbc_db2.inc.php b/drivers/adodb-odbc_db2.inc.php
index 8a75b92d..3d032323 100644
--- a/drivers/adodb-odbc_db2.inc.php
+++ b/drivers/adodb-odbc_db2.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -92,7 +92,7 @@ to DB2 full rights to the DB2 SQLLIB directory, and place the user in the DBUSER
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
if (!defined('ADODB_ODBC_DB2')){
define('ADODB_ODBC_DB2',1);
@@ -306,11 +306,6 @@ class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
var $databaseType = "db2";
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
-
function MetaType($t,$len=-1,$fieldobj=false)
{
if (is_object($t)) {
@@ -361,7 +356,7 @@ class ADORecordSet_odbc_db2 extends ADORecordSet_odbc {
case 'I':
return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
}
diff --git a/drivers/adodb-odbc_mssql.inc.php b/drivers/adodb-odbc_mssql.inc.php
index 65637d5b..bc28d261 100644
--- a/drivers/adodb-odbc_mssql.inc.php
+++ b/drivers/adodb-odbc_mssql.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -18,7 +18,7 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
@@ -47,12 +47,6 @@ 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 __construct()
- {
- parent::__construct();
- //$this->curmode = SQL_CUR_USE_ODBC;
- }
-
// crashes php...
function ServerInfo()
{
@@ -351,6 +345,56 @@ order by constraint_name, referenced_table_name, keyno";
}
return $s;
}
+
+ /**
+ * Returns a substring of a varchar type field
+ *
+ * The SQL server version varies because the length is mandatory, so
+ * we append a reasonable string length
+ *
+ * @param string $fld The field to sub-string
+ * @param int $start The start point
+ * @param int $length An optional length
+ *
+ * @return The SQL text
+ */
+ function substr($fld,$start,$length=0)
+ {
+ if ($length == 0)
+ /*
+ * The length available to varchar is 2GB, but that makes no
+ * sense in a substring, so I'm going to arbitrarily limit
+ * the length to 1K, but you could change it if you want
+ */
+ $length = 1024;
+
+ $text = "SUBSTRING($fld,$start,$length)";
+ return $text;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType C field. Because of the
+ * database design, SQL Server places no limits on the size of data inserted
+ * Although the actual limit is 2^31-1 bytes.
+ *
+ * @return int
+ */
+ function charMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType X field. Because of the
+ * database design, SQL Server places no limits on the size of data inserted
+ * Although the actual limit is 2^31-1 bytes.
+ *
+ * @return int
+ */
+ function textMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
}
@@ -358,8 +402,4 @@ class ADORecordSet_odbc_mssql extends ADORecordSet_odbc {
var $databaseType = 'odbc_mssql';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-odbc_mssql2012.inc.php b/drivers/adodb-odbc_mssql2012.inc.php
new file mode 100644
index 00000000..a3b7f69f
--- /dev/null
+++ b/drivers/adodb-odbc_mssql2012.inc.php
@@ -0,0 +1,28 @@
+<?php
+/*
+ @version v5.21.0-dev ??-???-2016
+ @copyright (c) 2015 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4.
+
+ Microsoft SQL Server 2012 via ODBC
+*/
+
+if (!defined('ADODB_DIR'))
+ die();
+
+include_once(ADODB_DIR."/drivers/adodb-odbc_mssql.inc.php");
+
+class ADODB_odbc_mssql2012 extends ADODB_odbc_mssql
+{
+ /*
+ * Makes behavior similar to prior versions of SQL Server
+ */
+ var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL ON';
+}
+
+class ADORecordSet_odbc_mssql2012 extends ADORecordSet_odbc_mssql
+{
+} \ No newline at end of file
diff --git a/drivers/adodb-odbc_oracle.inc.php b/drivers/adodb-odbc_oracle.inc.php
index ded5fcc9..eb83c1ee 100644
--- a/drivers/adodb-odbc_oracle.inc.php
+++ b/drivers/adodb-odbc_oracle.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -16,7 +16,7 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
@@ -103,8 +103,4 @@ class ADORecordSet_odbc_oracle extends ADORecordSet_odbc {
var $databaseType = 'odbc_oracle';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-odbtp.inc.php b/drivers/adodb-odbtp.inc.php
index 89c58a80..6beec767 100644
--- a/drivers/adodb-odbtp.inc.php
+++ b/drivers/adodb-odbtp.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -35,10 +35,6 @@ class ADODB_odbtp extends ADOConnection{
var $_canPrepareSP = false;
var $_dontPoolDBC = true;
- function __construct()
- {
- }
-
function ServerInfo()
{
return array('description' => @odbtp_get_attr( ODB_ATTR_DBMSNAME, $this->_connectionID),
@@ -793,48 +789,28 @@ class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_mssql';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_access';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_vfp';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_oci8';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {
var $databaseType = 'odbtp_sybase';
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
}
diff --git a/drivers/adodb-odbtp_unicode.inc.php b/drivers/adodb-odbtp_unicode.inc.php
index 92bf0159..22f93594 100644
--- a/drivers/adodb-odbtp_unicode.inc.php
+++ b/drivers/adodb-odbtp_unicode.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -26,7 +26,7 @@ if (!defined('ADODB_DIR')) die();
*/
if (!defined('_ADODB_ODBTP_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbtp.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbtp.inc.php");
}
class ADODB_odbtp_unicode extends ADODB_odbtp {
diff --git a/drivers/adodb-oracle.inc.php b/drivers/adodb-oracle.inc.php
index 6b2b2b29..daf9c8f3 100644
--- a/drivers/adodb-oracle.inc.php
+++ b/drivers/adodb-oracle.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -29,10 +29,6 @@ class ADODB_oracle extends ADOConnection {
var $sysTimeStamp = 'SYSDATE';
var $connectSID = true;
- function __construct()
- {
- }
-
// format and return date string in database date format
function DBDate($d, $isfld = false)
{
diff --git a/drivers/adodb-pdo.inc.php b/drivers/adodb-pdo.inc.php
index fcba2298..7eb4b3d2 100644
--- a/drivers/adodb-pdo.inc.php
+++ b/drivers/adodb-pdo.inc.php
@@ -1,6 +1,6 @@
<?php
/**
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
@@ -87,10 +87,6 @@ class ADODB_pdo extends ADOConnection {
var $stmt = false;
var $_driver;
- function __construct()
- {
- }
-
function _UpdatePDO()
{
$d = $this->_driver;
@@ -102,6 +98,7 @@ class ADODB_pdo extends ADOConnection {
$this->random = $d->random;
$this->concat_operator = $d->concat_operator;
$this->nameQuote = $d->nameQuote;
+ $this->arrayClass = $d->arrayClass;
$this->hasGenID = $d->hasGenID;
$this->_genIDSQL = $d->_genIDSQL;
@@ -175,6 +172,16 @@ class ADODB_pdo extends ADOConnection {
//$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT );
$this->_connectionID->setAttribute(PDO::ATTR_CASE,$m);
+ // Now merge in any provided attributes for PDO
+ foreach ($this->connectionParameters as $options) {
+ foreach($options as $k=>$v) {
+ if ($this->debug) {
+ ADOconnection::outp('Setting attribute: ' . $k . ' to ' . $v);
+ }
+ $this->_connectionID->setAttribute($k,$v);
+ }
+ }
+
$class = 'ADODB_pdo_'.$this->dsnType;
//$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true);
switch($this->dsnType) {
@@ -480,7 +487,9 @@ class ADODB_pdo extends ADOConnection {
#adodb_backtrace();
#var_dump($this->_bindInputArray);
if ($stmt) {
- $this->_driver->debug = $this->debug;
+ if (isset($this->_driver)) {
+ $this->_driver->debug = $this->debug;
+ }
if ($inputarr) {
$ok = $stmt->execute($inputarr);
}
@@ -812,3 +821,5 @@ class ADORecordSet_pdo extends ADORecordSet {
}
}
+
+class ADORecordSet_array_pdo extends ADORecordSet_array {}
diff --git a/drivers/adodb-pdo_mssql.inc.php b/drivers/adodb-pdo_mssql.inc.php
index 87a6ff19..d4d16a8f 100644
--- a/drivers/adodb-pdo_mssql.inc.php
+++ b/drivers/adodb-pdo_mssql.inc.php
@@ -2,7 +2,7 @@
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-pdo_mysql.inc.php b/drivers/adodb-pdo_mysql.inc.php
index 6e935db9..ca4f2727 100644
--- a/drivers/adodb-pdo_mysql.inc.php
+++ b/drivers/adodb-pdo_mysql.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-pdo_oci.inc.php b/drivers/adodb-pdo_oci.inc.php
index f33f7c5f..7776440e 100644
--- a/drivers/adodb-pdo_oci.inc.php
+++ b/drivers/adodb-pdo_oci.inc.php
@@ -2,7 +2,7 @@
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-pdo_pgsql.inc.php b/drivers/adodb-pdo_pgsql.inc.php
index 111d9efa..5ea81c2b 100644
--- a/drivers/adodb-pdo_pgsql.inc.php
+++ b/drivers/adodb-pdo_pgsql.inc.php
@@ -1,7 +1,7 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -229,4 +229,64 @@ select viewname,'V' from pg_views where viewname like $mask";
}
+ function BeginTrans()
+ {
+ if (!$this->hasTransactions) {
+ return false;
+ }
+ if ($this->transOff) {
+ return true;
+ }
+ $this->transCnt += 1;
+
+ return $this->_connectionID->beginTransaction();
+ }
+
+ function CommitTrans($ok = true)
+ {
+ 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();
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if (!$this->hasTransactions) {
+ return false;
+ }
+ if ($this->transOff) {
+ return true;
+ }
+ if ($this->transCnt) {
+ $this->transCnt -= 1;
+ }
+ $this->_autocommit = true;
+
+ $ret = $this->_connectionID->rollback();
+ return $ret;
+ }
+
+ function SetTransactionMode( $transaction_mode )
+ {
+ $this->_transmode = $transaction_mode;
+ if (empty($transaction_mode)) {
+ $this->_connectionID->query('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
+ return;
+ }
+ if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
+ $this->_connectionID->query("SET TRANSACTION ".$transaction_mode);
+ }
}
diff --git a/drivers/adodb-pdo_sqlite.inc.php b/drivers/adodb-pdo_sqlite.inc.php
index 524de31e..5cfdac66 100644
--- a/drivers/adodb-pdo_sqlite.inc.php
+++ b/drivers/adodb-pdo_sqlite.inc.php
@@ -1,7 +1,7 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-pdo_sqlsrv.inc.php b/drivers/adodb-pdo_sqlsrv.inc.php
index 869e8e18..ba5180ec 100644
--- a/drivers/adodb-pdo_sqlsrv.inc.php
+++ b/drivers/adodb-pdo_sqlsrv.inc.php
@@ -5,10 +5,10 @@
*/
class ADODB_pdo_sqlsrv extends ADODB_pdo
{
-
var $hasTop = 'top';
var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
var $sysTimeStamp = 'GetDate()';
+ var $arrayClass = 'ADORecordSet_array_pdo_sqlsrv';
function _init(ADODB_pdo $parentDriver)
{
@@ -45,5 +45,120 @@ class ADODB_pdo_sqlsrv extends ADODB_pdo
{
return ADOConnection::ServerInfo();
}
+}
+
+class ADORecordSet_pdo_sqlsrv extends ADORecordSet_pdo
+{
+
+ public $databaseType = "pdo_sqlsrv";
+
+ /**
+ * returns the field object
+ *
+ * @param int $fieldOffset Optional field offset
+ *
+ * @return object The ADOFieldObject describing the field
+ */
+ public function fetchField($fieldOffset = 0)
+ {
+
+ // Default behavior allows passing in of -1 offset, which crashes the method
+ if ($fieldOffset == -1) {
+ $fieldOffset++;
+ }
+
+ $o = new ADOFieldObject();
+ $arr = @$this->_queryID->getColumnMeta($fieldOffset);
+
+ if (!$arr) {
+ $o->name = 'bad getColumnMeta()';
+ $o->max_length = -1;
+ $o->type = 'VARCHAR';
+ $o->precision = 0;
+ return $o;
+ }
+ $o->name = $arr['name'];
+ if (isset($arr['sqlsrv:decl_type']) && $arr['sqlsrv:decl_type'] <> "null") {
+ // Use the SQL Server driver specific value
+ $o->type = $arr['sqlsrv:decl_type'];
+ } else {
+ $o->type = adodb_pdo_type($arr['pdo_type']);
+ }
+ $o->max_length = $arr['len'];
+ $o->precision = $arr['precision'];
+
+ 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;
+ }
+}
+
+class ADORecordSet_array_pdo_sqlsrv extends ADORecordSet_array_pdo
+{
+
+ /**
+ * returns the field object
+ *
+ * Note that this is a direct copy of the ADORecordSet_pdo_sqlsrv method
+ *
+ * @param int $fieldOffset Optional field offset
+ *
+ * @return object The ADOfieldobject describing the field
+ */
+ public function fetchField($fieldOffset = 0)
+ {
+ // Default behavior allows passing in of -1 offset, which crashes the method
+ if ($fieldOffset == -1) {
+ $fieldOffset++;
+ }
+ $o = new ADOFieldObject();
+ $arr = @$this->_queryID->getColumnMeta($fieldOffset);
+
+ if (!$arr) {
+ $o->name = 'bad getColumnMeta()';
+ $o->max_length = -1;
+ $o->type = 'VARCHAR';
+ $o->precision = 0;
+ return $o;
+ }
+ $o->name = $arr['name'];
+ if (isset($arr['sqlsrv:decl_type']) && $arr['sqlsrv:decl_type'] <> "null") {
+ // Use the SQL Server driver specific value
+ $o->type = $arr['sqlsrv:decl_type'];
+ } else {
+ $o->type = adodb_pdo_type($arr['pdo_type']);
+ }
+ $o->max_length = $arr['len'];
+ $o->precision = $arr['precision'];
+
+ 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;
+ }
+
+ function SetTransactionMode( $transaction_mode )
+ {
+ $this->_transmode = $transaction_mode;
+ if (empty($transaction_mode)) {
+ $this->_connectionID->query('SET TRANSACTION ISOLATION LEVEL READ COMMITTED');
+ return;
+ }
+ if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
+ $this->_connectionID->query("SET TRANSACTION ".$transaction_mode);
+ }
}
diff --git a/drivers/adodb-postgres.inc.php b/drivers/adodb-postgres.inc.php
index 4296c30a..784227d3 100644
--- a/drivers/adodb-postgres.inc.php
+++ b/drivers/adodb-postgres.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php
index 25ec8d04..99d6d047 100644
--- a/drivers/adodb-postgres64.inc.php
+++ b/drivers/adodb-postgres64.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -124,19 +124,40 @@ class ADODB_postgres64 extends ADOConnection{
// to know what the concequences are. The other values are correct (wheren't in 0.94)
// -- Freek Dijkstra
- function __construct()
+ /**
+ * Retrieve Server information.
+ * In addition to server version and desription, the function also returns
+ * the client version.
+ * @param bool $detailed If true, retrieve detailed version string (executes
+ * a SQL query) in addition to the version number
+ * @return array|bool Server info or false if version could not be retrieved
+ * e.g. if there is no active connection
+ */
+ function ServerInfo($detailed = true)
{
- // changes the metaColumnsSQL, adds columns: attnum[6]
- }
+ if (empty($this->version['version'])) {
+ // We don't have a connection, so we can't retrieve server info
+ if (!$this->_connectionID) {
+ return false;
+ }
- function ServerInfo()
- {
- if (isset($this->version)) return $this->version;
+ $version = pg_version($this->_connectionID);
+ $this->version = array(
+ // If PHP has been compiled with PostgreSQL 7.3 or lower, then
+ // server version is not set so we use pg_parameter_status()
+ // which includes logic to obtain values server_version
+ 'version' => isset($version['server'])
+ ? $version['server']
+ : pg_parameter_status($this->_connectionID, 'server_version'),
+ 'client' => $version['client'],
+ 'description' => null,
+ );
+ }
+ if ($detailed && $this->version['description'] === null) {
+ $this->version['description'] = $this->GetOne('select version()');
+ }
- $arr['description'] = $this->GetOne("select version()");
- $arr['version'] = ADOConnection::_findvers($arr['description']);
- $this->version = $arr;
- return $arr;
+ return $this->version;
}
function IfNull( $field, $ifNull )
@@ -430,13 +451,17 @@ class ADODB_postgres64 extends ADOConnection{
return $realblob;
}
- /*
- See http://www.postgresql.org/idocs/index.php?datatype-binary.html
-
- NOTE: SQL string literals (input strings) must be preceded with two backslashes
- due to the fact that they must pass through two parsers in the PostgreSQL
- backend.
- */
+ /**
+ * Encode binary value prior to DB storage.
+ *
+ * See https://www.postgresql.org/docs/current/static/datatype-binary.html
+ *
+ * NOTE: SQL string literals (input strings) must be preceded with two
+ * backslashes due to the fact that they must pass through two parsers in
+ * the PostgreSQL backend.
+ *
+ * @param string $blob
+ */
function BlobEncode($blob)
{
if (ADODB_PHPVER >= 0x5200) return pg_escape_bytea($this->_connectionID, $blob);
@@ -729,9 +754,9 @@ class ADODB_postgres64 extends ADOConnection{
if ($this->_connectionID === false) return false;
$this->Execute("set datestyle='ISO'");
- $info = $this->ServerInfo();
- $this->pgVersion = (float) substr($info['version'],0,3);
- if ($this->pgVersion >= 7.1) { // good till version 999
+ $info = $this->ServerInfo(false);
+
+ if (version_compare($info['version'], '7.1', '>=')) {
$this->_nestedSQL = true;
}
@@ -739,8 +764,11 @@ class ADODB_postgres64 extends ADOConnection{
# 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 ( !empty($this->connection->noBlobs) && version_compare($info['version'], '9.0', '>=')) {
- $this->Execute('set bytea_output=escape');
+ if (!empty($this->connection->noBlobs) && version_compare($info['version'], '9.0', '>=')) {
+ $version = pg_version($this->connectionID);
+ if (version_compare($info['client'], '9.2', '<')) {
+ $this->Execute('set bytea_output=escape');
+ }
}
return true;
@@ -1068,6 +1096,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
case 'NAME':
case 'BPCHAR':
case '_VARCHAR':
+ case 'CIDR':
case 'INET':
case 'MACADDR':
if ($len <= $this->blobSize) return 'C';
@@ -1111,7 +1140,7 @@ class ADORecordSet_postgres64 extends ADORecordSet{
return 'R';
default:
- return 'N';
+ return ADODB_DEFAULT_METATYPE;
}
}
diff --git a/drivers/adodb-postgres7.inc.php b/drivers/adodb-postgres7.inc.php
index 33b8adf7..a94e84bd 100644
--- a/drivers/adodb-postgres7.inc.php
+++ b/drivers/adodb-postgres7.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -309,12 +309,6 @@ class ADORecordSet_postgres7 extends ADORecordSet_postgres64{
var $databaseType = "postgres7";
-
- function __construct($queryID, $mode=false)
- {
- parent::__construct($queryID, $mode);
- }
-
// 10% speedup to move MoveNext to child class
function MoveNext()
{
@@ -341,11 +335,6 @@ class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
var $databaseType = "postgres7";
- function __construct($queryID, $mode=false)
- {
- parent::__construct($queryID, $mode);
- }
-
function _fetch()
{
if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) {
diff --git a/drivers/adodb-postgres8.inc.php b/drivers/adodb-postgres8.inc.php
index a4db3021..8c7253e0 100644
--- a/drivers/adodb-postgres8.inc.php
+++ b/drivers/adodb-postgres8.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-postgres9.inc.php b/drivers/adodb-postgres9.inc.php
index fcf30f35..86cd1b7a 100644
--- a/drivers/adodb-postgres9.inc.php
+++ b/drivers/adodb-postgres9.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
diff --git a/drivers/adodb-proxy.inc.php b/drivers/adodb-proxy.inc.php
index 423c7ba6..ed53195d 100644
--- a/drivers/adodb-proxy.inc.php
+++ b/drivers/adodb-proxy.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -15,19 +15,16 @@
if (!defined('ADODB_DIR')) die();
if (! defined("_ADODB_PROXY_LAYER")) {
- define("_ADODB_PROXY_LAYER", 1 );
- include(ADODB_DIR."/drivers/adodb-csv.inc.php");
+ define("_ADODB_PROXY_LAYER", 1 );
+ include_once(ADODB_DIR."/drivers/adodb-csv.inc.php");
- class ADODB_proxy extends ADODB_csv {
- var $databaseType = 'proxy';
- var $databaseProvider = 'csv';
- }
- class ADORecordset_proxy extends ADORecordset_csv {
+class ADODB_proxy extends ADODB_csv {
+ var $databaseType = 'proxy';
+ var $databaseProvider = 'csv';
+}
+
+class ADORecordset_proxy extends ADORecordset_csv {
var $databaseType = "proxy";
+}
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
- };
} // define
diff --git a/drivers/adodb-sapdb.inc.php b/drivers/adodb-sapdb.inc.php
index 51148b3d..a25491f7 100644
--- a/drivers/adodb-sapdb.inc.php
+++ b/drivers/adodb-sapdb.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -18,7 +18,7 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
if (!defined('ADODB_SAPDB')){
define('ADODB_SAPDB',1);
@@ -33,12 +33,6 @@ class ADODB_SAPDB extends ADODB_odbc {
var $hasInsertId = true;
var $_bindInputArray = true;
- function __construct()
- {
- //if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC;
- parent::__construct();
- }
-
function ServerInfo()
{
$info = ADODB_odbc::ServerInfo();
@@ -55,7 +49,7 @@ class ADODB_SAPDB extends ADODB_odbc {
return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos");
}
- function MetaIndexes ($table, $primary = FALSE, $owner = false)
+ function MetaIndexes ($table, $primary = FALSE, $owner = false)
{
$table = $this->Quote(strtoupper($table));
@@ -65,43 +59,43 @@ class ADODB_SAPDB extends ADODB_odbc {
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== FALSE) {
- $savem = $this->SetFetchMode(FALSE);
- }
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
- $rs = $this->Execute($sql);
- if (isset($savem)) {
- $this->SetFetchMode($savem);
- }
- $ADODB_FETCH_MODE = $save;
+ $rs = $this->Execute($sql);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
- if (!is_object($rs)) {
- return FALSE;
- }
+ if (!is_object($rs)) {
+ return FALSE;
+ }
$indexes = array();
while ($row = $rs->FetchRow()) {
- $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE';
- $indexes[$row[0]]['columns'][] = $row[2];
- }
+ $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE';
+ $indexes[$row[0]]['columns'][] = $row[2];
+ }
if ($primary) {
$indexes['SYSPRIMARYKEYINDEX'] = array(
'unique' => True, // by definition
'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"),
);
}
- return $indexes;
+ return $indexes;
}
function MetaColumns ($table, $normalize = true)
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
- $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
- if ($this->fetchMode !== FALSE) {
- $savem = $this->SetFetchMode(FALSE);
- }
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
$table = $this->Quote(strtoupper($table));
$retarr = array();
@@ -134,10 +128,10 @@ class ADODB_SAPDB extends ADODB_odbc {
}
$retarr[$fld->name] = $fld;
}
- if (isset($savem)) {
- $this->SetFetchMode($savem);
- }
- $ADODB_FETCH_MODE = $save;
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
return $retarr;
}
@@ -158,13 +152,13 @@ class ADODB_SAPDB extends ADODB_odbc {
/*
SelectLimit implementation problems:
- The following will return random 10 rows as order by performed after "WHERE rowno<10"
- which is not ideal...
+ The following will return random 10 rows as order by performed after "WHERE rowno<10"
+ which is not ideal...
- select * from table where rowno < 10 order by 1
+ select * from table where rowno < 10 order by 1
- This means that we have to use the adoconnection base class SelectLimit when
- there is an "order by".
+ This means that we have to use the adoconnection base class SelectLimit when
+ there is an "order by".
See http://listserv.sap.com/pipermail/sapdb.general/2002-January/010405.html
*/
@@ -172,14 +166,10 @@ class ADODB_SAPDB extends ADODB_odbc {
};
-class ADORecordSet_sapdb extends ADORecordSet_odbc {
+class ADORecordSet_sapdb extends ADORecordSet_odbc {
var $databaseType = "sapdb";
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
}
} //define
diff --git a/drivers/adodb-sqlanywhere.inc.php b/drivers/adodb-sqlanywhere.inc.php
index c433ebe5..8b8d9cb2 100644
--- a/drivers/adodb-sqlanywhere.inc.php
+++ b/drivers/adodb-sqlanywhere.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
reserved.
@@ -47,7 +47,7 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
if (!defined('ADODB_SYBASE_SQLANYWHERE')){
@@ -153,11 +153,6 @@ if (!defined('ADODB_SYBASE_SQLANYWHERE')){
var $databaseType = "sqlanywhere";
- function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
-
}; //class
diff --git a/drivers/adodb-sqlite.inc.php b/drivers/adodb-sqlite.inc.php
index 5996e712..c86bb403 100644
--- a/drivers/adodb-sqlite.inc.php
+++ b/drivers/adodb-sqlite.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -33,10 +33,6 @@ class ADODB_sqlite extends ADOConnection {
var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
- function __construct()
- {
- }
-
function ServerInfo()
{
$arr['version'] = sqlite_libversion();
@@ -355,6 +351,63 @@ class ADODB_sqlite extends ADOConnection {
return $indexes;
}
+ /**
+ * Returns the maximum size of a MetaType C field. Because of the
+ * database design, sqlite places no limits on the size of data inserted
+ *
+ * @return int
+ */
+ function charMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType X field. Because of the
+ * database design, sqlite places no limits on the size of data inserted
+ *
+ * @return int
+ */
+ function textMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /*
+ * Converts a date to a month only field and pads it to 2 characters
+ *
+ * @param str $fld The name of the field to process
+ * @return str The SQL Statement
+ */
+ function month($fld)
+ {
+ $x = "strftime('%m',$fld)";
+
+ return $x;
+ }
+
+ /*
+ * Converts a date to a day only field and pads it to 2 characters
+ *
+ * @param str $fld The name of the field to process
+ * @return str The SQL Statement
+ */
+ function day($fld) {
+ $x = "strftime('%d',$fld)";
+ return $x;
+ }
+
+ /*
+ * Converts a date to a year only field
+ *
+ * @param str $fld The name of the field to process
+ * @return str The SQL Statement
+ */
+ function year($fld) {
+ $x = "strftime('%Y',$fld)";
+
+ return $x;
+ }
}
/*--------------------------------------------------------------------------------------
diff --git a/drivers/adodb-sqlite3.inc.php b/drivers/adodb-sqlite3.inc.php
index e957fcc4..f09893c3 100644
--- a/drivers/adodb-sqlite3.inc.php
+++ b/drivers/adodb-sqlite3.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -33,10 +33,6 @@ class ADODB_sqlite3 extends ADOConnection {
var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
- function __construct()
- {
- }
-
function ServerInfo()
{
$version = SQLite3::version();
@@ -82,6 +78,73 @@ class ADODB_sqlite3 extends ADOConnection {
return !empty($ret);
}
+ function metaType($t,$len=-1,$fieldobj=false)
+ {
+
+ if (is_object($t))
+ {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $t = strtoupper($t);
+
+ /*
+ * We are using the Sqlite affinity method here
+ * @link https://www.sqlite.org/datatype3.html
+ */
+ $affinity = array(
+ 'INT'=>'INTEGER',
+ 'INTEGER'=>'INTEGER',
+ 'TINYINT'=>'INTEGER',
+ 'SMALLINT'=>'INTEGER',
+ 'MEDIUMINT'=>'INTEGER',
+ 'BIGINT'=>'INTEGER',
+ 'UNSIGNED BIG INT'=>'INTEGER',
+ 'INT2'=>'INTEGER',
+ 'INT8'=>'INTEGER',
+
+ 'CHARACTER'=>'TEXT',
+ 'VARCHAR'=>'TEXT',
+ 'VARYING CHARACTER'=>'TEXT',
+ 'NCHAR'=>'TEXT',
+ 'NATIVE CHARACTER'=>'TEXT',
+ 'NVARCHAR'=>'TEXT',
+ 'TEXT'=>'TEXT',
+ 'CLOB'=>'TEXT',
+
+ 'BLOB'=>'BLOB',
+
+ 'REAL'=>'REAL',
+ 'DOUBLE'=>'REAL',
+ 'DOUBLE PRECISION'=>'REAL',
+ 'FLOAT'=>'REAL',
+
+ 'NUMERIC'=>'NUMERIC',
+ 'DECIMAL'=>'NUMERIC',
+ 'BOOLEAN'=>'NUMERIC',
+ 'DATE'=>'NUMERIC',
+ 'DATETIME'=>'NUMERIC'
+ );
+
+ if (!isset($affinity[$t]))
+ return ADODB_DEFAULT_METATYPE;
+
+ $subt = $affinity[$t];
+ /*
+ * Now that we have subclassed the provided data down
+ * the sqlite 'affinity', we convert to ADOdb metatype
+ */
+
+ $subclass = array('INTEGER'=>'I',
+ 'TEXT'=>'X',
+ 'BLOB'=>'B',
+ 'REAL'=>'N',
+ 'NUMERIC'=>'N');
+
+ return $subclass[$subt];
+ }
// mark newnham
function MetaColumns($table, $normalize=true)
{
@@ -129,6 +192,60 @@ class ADODB_sqlite3 extends ADOConnection {
return $arr;
}
+ 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;
+
+ /*
+ * Read sqlite master to find foreign keys
+ */
+ $sql = "SELECT sql
+ FROM (
+ SELECT sql sql, type type, tbl_name tbl_name, name name
+ FROM sqlite_master
+ )
+ WHERE type != 'meta'
+ AND sql NOTNULL
+ AND LOWER(name) ='" . strtolower($table) . "'";
+
+ $tableSql = $this->getOne($sql);
+
+ $fkeyList = array();
+ $ylist = preg_split("/,+/",$tableSql);
+ foreach ($ylist as $y)
+ {
+ if (!preg_match('/FOREIGN/',$y))
+ continue;
+
+ $matches = false;
+ preg_match_all('/\((.+?)\)/i',$y,$matches);
+ $tmatches = false;
+ preg_match_all('/REFERENCES (.+?)\(/i',$y,$tmatches);
+
+ if ($associative)
+ {
+ if (!isset($fkeyList[$tmatches[1][0]]))
+ $fkeyList[$tmatches[1][0]] = array();
+ $fkeyList[$tmatches[1][0]][$matches[1][0]] = $matches[1][1];
+ }
+ else
+ $fkeyList[$tmatches[1][0]][] = $matches[1][0] . '=' . $matches[1][1];
+ }
+
+ if ($associative)
+ {
+ if ($upper)
+ $fkeyList = array_change_key_case($fkeyList,CASE_UPPER);
+ else
+ $fkeyList = array_change_key_case($fkeyList,CASE_LOWER);
+ }
+ return $fkeyList;
+ }
+
+
function _init($parentDriver)
{
$parentDriver->hasTransactions = false;
@@ -160,11 +277,22 @@ class ADODB_sqlite3 extends ADOConnection {
function SQLDate($fmt, $col=false)
{
+ /*
+ * In order to map the values correctly, we must ensure the proper
+ * casing for certain fields
+ * Y must be UC, because y is a 2 digit year
+ * d must be LC, because D is 3 char day
+ * A must be UC because a is non-portable am
+ * Q must be UC because q means nothing
+ */
+ $fromChars = array('y','D','a','q');
+ $toChars = array('Y','d','A','Q');
+ $fmt = str_replace($fromChars,$toChars,$fmt);
+
$fmt = $this->qstr($fmt);
return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)";
}
-
function _createFunctions()
{
$this->_connectionID->createFunction('adodb_date', 'adodb_date', 1);
@@ -299,7 +427,7 @@ class ADODB_sqlite3 extends ADOConnection {
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));
+ $SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND LOWER(tbl_name)='%s'", strtolower($table));
$rs = $this->Execute($SQL);
if (!is_object($rs)) {
if (isset($savem)) {
@@ -338,6 +466,72 @@ class ADODB_sqlite3 extends ADOConnection {
return $indexes;
}
+ /**
+ * Returns the maximum size of a MetaType C field. Because of the
+ * database design, sqlite places no limits on the size of data inserted
+ *
+ * @return int
+ */
+ function charMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /**
+ * Returns the maximum size of a MetaType X field. Because of the
+ * database design, sqlite places no limits on the size of data inserted
+ *
+ * @return int
+ */
+ function textMax()
+ {
+ return ADODB_STRINGMAX_NOLIMIT;
+ }
+
+ /**
+ * Converts a date to a month only field and pads it to 2 characters
+ *
+ * This uses the more efficient strftime native function to process
+ *
+ * @param str $fld The name of the field to process
+ *
+ * @return str The SQL Statement
+ */
+ function month($fld)
+ {
+ $x = "strftime('%m',$fld)";
+ return $x;
+ }
+
+ /**
+ * Converts a date to a day only field and pads it to 2 characters
+ *
+ * This uses the more efficient strftime native function to process
+ *
+ * @param str $fld The name of the field to process
+ *
+ * @return str The SQL Statement
+ */
+ function day($fld) {
+ $x = "strftime('%d',$fld)";
+ return $x;
+ }
+
+ /**
+ * Converts a date to a year only field
+ *
+ * This uses the more efficient strftime native function to process
+ *
+ * @param str $fld The name of the field to process
+ *
+ * @return str The SQL Statement
+ */
+ function year($fld)
+ {
+ $x = "strftime('%Y',$fld)";
+ return $x;
+ }
+
}
/*--------------------------------------------------------------------------------------
diff --git a/drivers/adodb-sqlitepo.inc.php b/drivers/adodb-sqlitepo.inc.php
index 60fe456c..f9c99835 100644
--- a/drivers/adodb-sqlitepo.inc.php
+++ b/drivers/adodb-sqlitepo.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -35,11 +35,6 @@ class ADORecordset_sqlitepo extends ADORecordset_sqlite {
var $databaseType = 'sqlitepo';
- function __construct($queryID,$mode=false)
- {
- parent::__construct($queryID,$mode);
- }
-
// Modified to strip table names from returned fields
function _fetch($ignore_fields=false)
{
diff --git a/drivers/adodb-sybase.inc.php b/drivers/adodb-sybase.inc.php
index 4e4dd53d..8604e24c 100644
--- a/drivers/adodb-sybase.inc.php
+++ b/drivers/adodb-sybase.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim. All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -44,10 +44,6 @@ class ADODB_sybase extends ADOConnection {
var $port;
- function __construct()
- {
- }
-
// might require begintrans -- committrans
function _insertid()
{
@@ -321,7 +317,7 @@ class ADORecordset_sybase extends ADORecordSet {
}
if (!$mode) $this->fetchMode = ADODB_FETCH_ASSOC;
else $this->fetchMode = $mode;
- parent::__construct($id,$mode);
+ parent::__construct($id);
}
/* Returns: an object containing field information.
@@ -394,12 +390,8 @@ class ADORecordset_sybase extends ADORecordSet {
}
class ADORecordSet_array_sybase extends ADORecordSet_array {
- function __construct($id=-1)
- {
- parent::__construct($id);
- }
- // sybase/mssql uses a default date like Dec 30 2000 12:00AM
+ // sybase/mssql uses a default date like Dec 30 2000 12:00AM
static function UnixDate($v)
{
global $ADODB_sybase_mths;
diff --git a/drivers/adodb-sybase_ase.inc.php b/drivers/adodb-sybase_ase.inc.php
index 34ec807e..13211f5c 100644
--- a/drivers/adodb-sybase_ase.inc.php
+++ b/drivers/adodb-sybase_ase.inc.php
@@ -1,6 +1,6 @@
<?php
/*
- @version v5.20.10 08-Mar-2018
+ @version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -22,10 +22,6 @@ 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 __construct()
- {
- }
-
// split the Views, Tables and procedures.
function MetaTables($ttype=false,$showSchema=false,$mask=false)
{
@@ -111,10 +107,5 @@ class ADODB_sybase_ase extends ADODB_sybase {
}
class adorecordset_sybase_ase extends ADORecordset_sybase {
-var $databaseType = "sybase_ase";
-function __construct($id,$mode=false)
- {
- parent::__construct($id,$mode);
- }
-
+ var $databaseType = "sybase_ase";
}
diff --git a/drivers/adodb-text.inc.php b/drivers/adodb-text.inc.php
index ad9d417e..8e11973f 100644
--- a/drivers/adodb-text.inc.php
+++ b/drivers/adodb-text.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@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.
@@ -90,10 +90,6 @@ class ADODB_text extends ADOConnection {
var $_reznames;
var $_reztypes;
- function __construct()
- {
- }
-
function RSRecordCount()
{
if (!empty($this->_rezarray)) return sizeof($this->_rezarray);
diff --git a/drivers/adodb-vfp.inc.php b/drivers/adodb-vfp.inc.php
index 1b0694bf..545c468b 100644
--- a/drivers/adodb-vfp.inc.php
+++ b/drivers/adodb-vfp.inc.php
@@ -1,6 +1,6 @@
<?php
/*
-@version v5.20.10 08-Mar-2018
+@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
Released under both BSD license and Lesser GPL library license.
@@ -17,7 +17,7 @@ Set tabs to 4 for best viewing.
if (!defined('ADODB_DIR')) die();
if (!defined('_ADODB_ODBC_LAYER')) {
- include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+ include_once(ADODB_DIR."/drivers/adodb-odbc.inc.php");
}
if (!defined('ADODB_VFP')){
define('ADODB_VFP',1);
@@ -69,11 +69,6 @@ class ADORecordSet_vfp extends ADORecordSet_odbc {
var $databaseType = "vfp";
- function __construct($id,$mode=false)
- {
- return parent::__construct($id,$mode);
- }
-
function MetaType($t, $len = -1, $fieldobj = false)
{
if (is_object($t)) {
@@ -95,7 +90,7 @@ class ADORecordSet_vfp extends ADORecordSet_odbc {
case 'I': return 'I';
- default: return 'N';
+ default: return ADODB_DEFAULT_METATYPE;
}
}
}