Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/vendor/adodb/adodb-php/datadict
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/adodb/adodb-php/datadict')
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-access.inc.php95
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-db2.inc.php143
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php151
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-generic.inc.php127
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-ibase.inc.php67
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-informix.inc.php81
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-mssql.inc.php285
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-mssqlnative.inc.php369
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-mysql.inc.php183
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-oci8.inc.php300
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-postgres.inc.php484
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-sapdb.inc.php122
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-sqlite.inc.php90
-rw-r--r--vendor/adodb/adodb-php/datadict/datadict-sybase.inc.php230
14 files changed, 2727 insertions, 0 deletions
diff --git a/vendor/adodb/adodb-php/datadict/datadict-access.inc.php b/vendor/adodb/adodb-php/datadict/datadict-access.inc.php
new file mode 100644
index 0000000..490ded0
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-access.inc.php
@@ -0,0 +1,95 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_access extends ADODB_DataDict {
+
+ var $databaseType = 'access';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'TEXT';
+ case 'XL':
+ case 'X': return 'MEMO';
+
+ case 'C2': return 'TEXT'; // up to 32K
+ case 'X2': return 'MEMO';
+
+ case 'B': return 'BINARY';
+
+ case 'TS':
+ case 'D': return 'DATETIME';
+ case 'T': return 'DATETIME';
+
+ case 'L': return 'BYTE';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'BYTE';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'INTEGER';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ if ($fautoinc) {
+ $ftype = 'COUNTER';
+ return '';
+ }
+ if (substr($ftype,0,7) == 'DECIMAL') $ftype = 'DECIMAL';
+ $suffix = '';
+ if (strlen($fdefault)) {
+ //$suffix .= " DEFAULT $fdefault";
+ if ($this->debug) ADOConnection::outp("Warning: Access does not supported DEFAULT values (field $fname)");
+ }
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function CreateDatabase($dbname,$options=false)
+ {
+ return array();
+ }
+
+
+ function SetSchema($schema)
+ {
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-db2.inc.php b/vendor/adodb/adodb-php/datadict/datadict-db2.inc.php
new file mode 100644
index 0000000..a9aa34d
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-db2.inc.php
@@ -0,0 +1,143 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_db2 extends ADODB_DataDict {
+
+ var $databaseType = 'db2';
+ var $seqField = false;
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL': return 'CLOB';
+ case 'X': return 'VARCHAR(3600)';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR(3600)'; // up to 32000, but default page size too small
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($fautoinc) return ' GENERATED ALWAYS AS IDENTITY'; # as identity start with
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+
+ function ChangeTableSQL($tablename, $flds, $tableoptions = false)
+ {
+
+ /**
+ Allow basic table changes to DB2 databases
+ DB2 will fatally reject changes to non character columns
+
+ */
+
+ $validTypes = array("CHAR","VARC");
+ $invalidTypes = array("BIGI","BLOB","CLOB","DATE", "DECI","DOUB", "INTE", "REAL","SMAL", "TIME");
+ // check table exists
+ $cols = $this->MetaColumns($tablename);
+ if ( empty($cols)) {
+ return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+ }
+
+ // already exists, alter table instead
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+ $sql = array();
+
+ foreach ( $lines as $id => $v ) {
+ if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+ /**
+ If the first field of $v is the fieldname, and
+ the second is the field type/size, we assume its an
+ attempt to modify the column size, so check that it is allowed
+ $v can have an indeterminate number of blanks between the
+ fields, so account for that too
+ */
+ $vargs = explode(' ' , $v);
+ // assume that $vargs[0] is the field name.
+ $i=0;
+ // Find the next non-blank value;
+ for ($i=1;$i<sizeof($vargs);$i++)
+ if ($vargs[$i] != '')
+ break;
+
+ // if $vargs[$i] is one of the following, we are trying to change the
+ // size of the field, if not allowed, simply ignore the request.
+ if (in_array(substr($vargs[$i],0,4),$invalidTypes))
+ continue;
+ // insert the appropriate DB2 syntax
+ if (in_array(substr($vargs[$i],0,4),$validTypes)) {
+ array_splice($vargs,$i,0,array('SET','DATA','TYPE'));
+ }
+
+ // Now Look for the NOT NULL statement as this is not allowed in
+ // the ALTER table statement. If it is in there, remove it
+ if (in_array('NOT',$vargs) && in_array('NULL',$vargs)) {
+ for ($i=1;$i<sizeof($vargs);$i++)
+ if ($vargs[$i] == 'NOT')
+ break;
+ array_splice($vargs,$i,2,'');
+ }
+ $v = implode(' ',$vargs);
+ $sql[] = $alter . $this->alterCol . ' ' . $v;
+ } else {
+ $sql[] = $alter . $this->addCol . ' ' . $v;
+ }
+ }
+
+ return $sql;
+ }
+
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php b/vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php
new file mode 100644
index 0000000..cffcca1
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php
@@ -0,0 +1,151 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+class ADODB2_firebird extends ADODB_DataDict {
+
+ var $databaseType = 'firebird';
+ var $seqField = false;
+ var $seqPrefix = 'gen_';
+ var $blobSize = 40000;
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL': return 'VARCHAR(32000)';
+ case 'X': return 'VARCHAR(4000)';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR(4000)';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'INTEGER';
+
+ case 'F': return 'DOUBLE PRECISION';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function NameQuote($name = NULL)
+ {
+ if (!is_string($name)) {
+ return FALSE;
+ }
+
+ $name = trim($name);
+
+ if ( !is_object($this->connection) ) {
+ return $name;
+ }
+
+ $quote = $this->connection->nameQuote;
+
+ // if name is of the form `name`, quote it
+ if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
+ return $quote . $matches[1] . $quote;
+ }
+
+ // if name contains special characters, quote it
+ if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) {
+ return $quote . $name . $quote;
+ }
+
+ return $quote . $name . $quote;
+ }
+
+ function CreateDatabase($dbname, $options=false)
+ {
+ $options = $this->_Options($options);
+ $sql = array();
+
+ $sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'";
+
+ return $sql;
+ }
+
+ function _DropAutoIncrement($t)
+ {
+ if (strpos($t,'.') !== false) {
+ $tarr = explode('.',$t);
+ return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"';
+ }
+ return 'DROP GENERATOR "GEN_'.$t;
+ }
+
+
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fautoinc) $this->seqField = $fname;
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+
+ return $suffix;
+ }
+
+/*
+CREATE or replace TRIGGER jaddress_insert
+before insert on jaddress
+for each row
+begin
+IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN
+ NEW."seqField" = GEN_ID("GEN_tabname", 1);
+end;
+*/
+ function _Triggers($tabname,$tableoptions)
+ {
+ if (!$this->seqField) return array();
+
+ $tab1 = preg_replace( '/"/', '', $tabname );
+ if ($this->schema) {
+ $t = strpos($tab1,'.');
+ if ($t !== false) $tab = substr($tab1,$t+1);
+ else $tab = $tab1;
+ $seqField = $this->seqField;
+ $seqname = $this->schema.'.'.$this->seqPrefix.$tab;
+ $trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab;
+ } else {
+ $seqField = $this->seqField;
+ $seqname = $this->seqPrefix.$tab1;
+ $trigname = 'trig_'.$seqname;
+ }
+ if (isset($tableoptions['REPLACE']))
+ { $sql[] = "DROP GENERATOR \"$seqname\"";
+ $sql[] = "CREATE GENERATOR \"$seqname\"";
+ $sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
+ }
+ else
+ { $sql[] = "CREATE GENERATOR \"$seqname\"";
+ $sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
+ }
+
+ $this->seqField = false;
+ return $sql;
+ }
+
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-generic.inc.php b/vendor/adodb/adodb-php/datadict/datadict-generic.inc.php
new file mode 100644
index 0000000..183f959
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-generic.inc.php
@@ -0,0 +1,127 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_generic extends ADODB_DataDict {
+
+ var $databaseType = 'generic';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'VARCHAR(250)';
+
+ case 'C2': return 'VARCHAR';
+ case 'X2': return 'VARCHAR(250)';
+
+ case 'B': return 'VARCHAR';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'DATE';
+
+ case 'L': return 'DECIMAL(1)';
+ case 'I': return 'DECIMAL(10)';
+ case 'I1': return 'DECIMAL(3)';
+ case 'I2': return 'DECIMAL(5)';
+ case 'I4': return 'DECIMAL(10)';
+ case 'I8': return 'DECIMAL(20)';
+
+ case 'F': return 'DECIMAL(32,8)';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+}
+
+/*
+//db2
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'X': return 'VARCHAR';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+// ifx
+function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';// 255
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'TEXT';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'DATETIME';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'DECIMAL(20)';
+
+ case 'F': return 'FLOAT';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+*/
diff --git a/vendor/adodb/adodb-php/datadict/datadict-ibase.inc.php b/vendor/adodb/adodb-php/datadict/datadict-ibase.inc.php
new file mode 100644
index 0000000..257581e
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-ibase.inc.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_ibase extends ADODB_DataDict {
+
+ var $databaseType = 'ibase';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'VARCHAR(4000)';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR(4000)';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'INTEGER';
+
+ case 'F': return 'DOUBLE PRECISION';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-informix.inc.php b/vendor/adodb/adodb-php/datadict/datadict-informix.inc.php
new file mode 100644
index 0000000..df03deb
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-informix.inc.php
@@ -0,0 +1,81 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_informix extends ADODB_DataDict {
+
+ var $databaseType = 'informix';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';// 255
+ case 'XL':
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'TEXT';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'DATETIME YEAR TO SECOND';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'DECIMAL(20)';
+
+ case 'F': return 'FLOAT';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ if ($fautoinc) {
+ $ftype = 'SERIAL';
+ return '';
+ }
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-mssql.inc.php b/vendor/adodb/adodb-php/datadict/datadict-mssql.inc.php
new file mode 100644
index 0000000..0b6a051
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-mssql.inc.php
@@ -0,0 +1,285 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+/*
+In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
+
+ Note Delimiters are for identifiers only. Delimiters cannot be used for keywords,
+ whether or not they are marked as reserved in SQL Server.
+
+ Quoted identifiers are delimited by double quotation marks ("):
+ SELECT * FROM "Blanks in Table Name"
+
+ Bracketed identifiers are delimited by brackets ([ ]):
+ SELECT * FROM [Blanks In Table Name]
+
+ Quoted identifiers are valid only when the QUOTED_IDENTIFIER option is set to ON. By default,
+ the Microsoft OLE DB Provider for SQL Server and SQL Server ODBC driver set QUOTED_IDENTIFIER ON
+ when they connect.
+
+ In Transact-SQL, the option can be set at various levels using SET QUOTED_IDENTIFIER,
+ the quoted identifier option of sp_dboption, or the user options option of sp_configure.
+
+ When SET ANSI_DEFAULTS is ON, SET QUOTED_IDENTIFIER is enabled.
+
+ Syntax
+
+ SET QUOTED_IDENTIFIER { ON | OFF }
+
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_mssql extends ADODB_DataDict {
+ var $databaseType = 'mssql';
+ var $dropIndex = 'DROP INDEX %2$s.%1$s';
+ var $renameTable = "EXEC sp_rename '%s','%s'";
+ var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
+
+ var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
+ var $typeXL = 'TEXT';
+
+ //var $alterCol = ' ALTER COLUMN ';
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'R':
+ case 'INT':
+ case 'INTEGER': return 'I';
+ case 'BIT':
+ case 'TINYINT': return 'I1';
+ case 'SMALLINT': return 'I2';
+ case 'BIGINT': return 'I8';
+ case 'SMALLDATETIME': return 'T';
+ case 'REAL':
+ case 'FLOAT': return 'F';
+ default: return parent::MetaType($t,$len,$fieldobj);
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+
+ case 'C': return 'VARCHAR';
+ case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT';
+ case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'NTEXT';
+
+ case 'B': return 'IMAGE';
+
+ case 'D': return 'DATETIME';
+
+ case 'TS':
+ case 'T': return 'DATETIME';
+ case 'L': return 'BIT';
+
+ case 'R':
+ case 'I': return 'INT';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'REAL';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname $this->addCol";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ /*
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ foreach($lines as $v) {
+ $sql[] = "ALTER TABLE $tabname $this->alterCol $v";
+ }
+
+ return $sql;
+ }
+ */
+
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds))
+ $flds = explode(',',$flds);
+ $f = array();
+ $s = 'ALTER TABLE ' . $tabname;
+ foreach($flds as $v) {
+ $f[] = "\n$this->dropCol ".$this->NameQuote($v);
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' IDENTITY(1,1)';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ else if ($suffix == '') $suffix .= ' NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+CREATE TABLE
+ [ database_name.[ owner ] . | owner. ] table_name
+ ( { < column_definition >
+ | column_name AS computed_column_expression
+ | < table_constraint > ::= [ CONSTRAINT constraint_name ] }
+
+ | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
+ )
+
+[ ON { filegroup | DEFAULT } ]
+[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
+
+< column_definition > ::= { column_name data_type }
+ [ COLLATE < collation_name > ]
+ [ [ DEFAULT constant_expression ]
+ | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
+ ]
+ [ ROWGUIDCOL]
+ [ < column_constraint > ] [ ...n ]
+
+< column_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ NULL | NOT NULL ]
+ | [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ [ WITH FILLFACTOR = fillfactor ]
+ [ON {filegroup | DEFAULT} ] ]
+ ]
+ | [ [ FOREIGN KEY ]
+ REFERENCES ref_table [ ( ref_column ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( logical_expression )
+ }
+
+< table_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ { ( column [ ASC | DESC ] [ ,...n ] ) }
+ [ WITH FILLFACTOR = fillfactor ]
+ [ ON { filegroup | DEFAULT } ]
+ ]
+ | FOREIGN KEY
+ [ ( column [ ,...n ] ) ]
+ REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( search_conditions )
+ }
+
+
+ */
+
+ /*
+ CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
+ ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
+ [ WITH < index_option > [ ,...n] ]
+ [ ON filegroup ]
+ < index_option > :: =
+ { PAD_INDEX |
+ FILLFACTOR = fillfactor |
+ IGNORE_DUP_KEY |
+ DROP_EXISTING |
+ STATISTICS_NORECOMPUTE |
+ SORT_IN_TEMPDB
+ }
+*/
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+ $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+
+ function _GetSize($ftype, $ty, $fsize, $fprec)
+ {
+ switch ($ftype) {
+ case 'INT':
+ case 'SMALLINT':
+ case 'TINYINT':
+ case 'BIGINT':
+ return $ftype;
+ }
+ if ($ty == 'T') return $ftype;
+ return parent::_GetSize($ftype, $ty, $fsize, $fprec);
+
+ }
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-mssqlnative.inc.php b/vendor/adodb/adodb-php/datadict/datadict-mssqlnative.inc.php
new file mode 100644
index 0000000..51f7d2a
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-mssqlnative.inc.php
@@ -0,0 +1,369 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+/*
+In ADOdb, named quotes for MS SQL Server use ". From the MSSQL Docs:
+
+ Note Delimiters are for identifiers only. Delimiters cannot be used for keywords,
+ whether or not they are marked as reserved in SQL Server.
+
+ Quoted identifiers are delimited by double quotation marks ("):
+ SELECT * FROM "Blanks in Table Name"
+
+ Bracketed identifiers are delimited by brackets ([ ]):
+ SELECT * FROM [Blanks In Table Name]
+
+ Quoted identifiers are valid only when the QUOTED_IDENTIFIER option is set to ON. By default,
+ the Microsoft OLE DB Provider for SQL Server and SQL Server ODBC driver set QUOTED_IDENTIFIER ON
+ when they connect.
+
+ In Transact-SQL, the option can be set at various levels using SET QUOTED_IDENTIFIER,
+ the quoted identifier option of sp_dboption, or the user options option of sp_configure.
+
+ When SET ANSI_DEFAULTS is ON, SET QUOTED_IDENTIFIER is enabled.
+
+ Syntax
+
+ SET QUOTED_IDENTIFIER { ON | OFF }
+
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_mssqlnative extends ADODB_DataDict {
+ var $databaseType = 'mssqlnative';
+ var $dropIndex = 'DROP INDEX %1$s ON %2$s';
+ var $renameTable = "EXEC sp_rename '%s','%s'";
+ var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
+ var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
+ var $typeXL = 'TEXT';
+
+ //var $alterCol = ' ALTER COLUMN ';
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $_typeConversion = array(
+ -155 => 'D',
+ 93 => 'D',
+ -154 => 'D',
+ -2 => 'D',
+ 91 => 'D',
+
+ 12 => 'C',
+ 1 => 'C',
+ -9 => 'C',
+ -8 => 'C',
+
+ -7 => 'L',
+ -6 => 'I2',
+ -5 => 'I8',
+ -11 => 'I',
+ 4 => 'I',
+ 5 => 'I4',
+
+ -1 => 'X',
+ -10 => 'X',
+
+ 2 => 'N',
+ 3 => 'N',
+ 6 => 'N',
+ 7 => 'N',
+
+ -152 => 'X',
+ -151 => 'X',
+ -4 => 'X',
+ -3 => 'X'
+ );
+
+ return $_typeConversion($t);
+
+ }
+
+ function ActualType($meta)
+ {
+ $DATE_TYPE = 'DATETIME';
+
+ switch(strtoupper($meta)) {
+
+ case 'C': return 'VARCHAR';
+ case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT';
+ case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'NTEXT';
+
+ case 'B': return 'IMAGE';
+
+ case 'D': return $DATE_TYPE;
+ case 'T': return 'TIME';
+ case 'L': return 'BIT';
+
+ case 'R':
+ case 'I': return 'INT';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'REAL';
+ case 'N': return 'NUMERIC';
+ default:
+ print "RETURN $meta";
+ return $meta;
+ }
+ }
+
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname $this->addCol";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function DefaultConstraintname($tabname, $colname)
+ {
+ $constraintname = false;
+ $rs = $this->connection->Execute(
+ "SELECT name FROM sys.default_constraints
+ WHERE object_name(parent_object_id) = '$tabname'
+ AND col_name(parent_object_id, parent_column_id) = '$colname'"
+ );
+ if ( is_object($rs) ) {
+ $row = $rs->FetchRow();
+ $constraintname = $row['name'];
+ }
+ return $constraintname;
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+
+ list($lines,$pkey,$idxs) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+ foreach($lines as $v) {
+ $not_null = false;
+ if ($not_null = preg_match('/NOT NULL/i',$v)) {
+ $v = preg_replace('/NOT NULL/i','',$v);
+ }
+ if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) {
+ list(,$colname,$default) = $matches;
+ $v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
+ $t = trim(str_replace('DEFAULT '.$default,'',$v));
+ if ( $constraintname = $this->DefaultConstraintname($tabname,$colname) ) {
+ $sql[] = 'ALTER TABLE '.$tabname.' DROP CONSTRAINT '. $constraintname;
+ }
+ if ($not_null) {
+ $sql[] = $alter . $colname . ' ' . $t . ' NOT NULL';
+ } else {
+ $sql[] = $alter . $colname . ' ' . $t ;
+ }
+ $sql[] = 'ALTER TABLE ' . $tabname
+ . ' ADD CONSTRAINT DF__' . $tabname . '__' . $colname . '__' . dechex(rand())
+ . ' DEFAULT ' . $default . ' FOR ' . $colname;
+ } else {
+ $colname = strtok($v," ");
+ if ( $constraintname = $this->DefaultConstraintname($tabname,$colname) ) {
+ $sql[] = 'ALTER TABLE '.$tabname.' DROP CONSTRAINT '. $constraintname;
+ }
+ if ($not_null) {
+ $sql[] = $alter . $v . ' NOT NULL';
+ } else {
+ $sql[] = $alter . $v;
+ }
+ }
+ }
+ if (is_array($idxs)) {
+ foreach($idxs as $idx => $idxdef) {
+ $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']);
+ $sql = array_merge($sql, $sql_idxs);
+ }
+ }
+ return $sql;
+ }
+
+
+ /**
+ * Drop a column, syntax is ALTER TABLE table DROP COLUMN column,column
+ *
+ * @param string $tabname Table Name
+ * @param string[] $flds One, or an array of Fields To Drop
+ * @param string $tableflds Throwaway value to make the function match the parent
+ * @param string $tableoptions Throway value to make the function match the parent
+ *
+ * @return string The SQL necessary to drop the column
+ */
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds))
+ $flds = explode(',',$flds);
+ $f = array();
+ $s = 'ALTER TABLE ' . $tabname;
+ foreach($flds as $v) {
+ if ( $constraintname = $this->DefaultConstraintname($tabname,$v) ) {
+ $sql[] = 'ALTER TABLE ' . $tabname . ' DROP CONSTRAINT ' . $constraintname;
+ }
+ $f[] = ' DROP COLUMN ' . $this->NameQuote($v);
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' IDENTITY(1,1)';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ else if ($suffix == '') $suffix .= ' NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+CREATE TABLE
+ [ database_name.[ owner ] . | owner. ] table_name
+ ( { < column_definition >
+ | column_name AS computed_column_expression
+ | < table_constraint > ::= [ CONSTRAINT constraint_name ] }
+
+ | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
+ )
+
+[ ON { filegroup | DEFAULT } ]
+[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
+
+< column_definition > ::= { column_name data_type }
+ [ COLLATE < collation_name > ]
+ [ [ DEFAULT constant_expression ]
+ | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
+ ]
+ [ ROWGUIDCOL]
+ [ < column_constraint > ] [ ...n ]
+
+< column_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ NULL | NOT NULL ]
+ | [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ [ WITH FILLFACTOR = fillfactor ]
+ [ON {filegroup | DEFAULT} ] ]
+ ]
+ | [ [ FOREIGN KEY ]
+ REFERENCES ref_table [ ( ref_column ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( logical_expression )
+ }
+
+< table_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ { ( column [ ASC | DESC ] [ ,...n ] ) }
+ [ WITH FILLFACTOR = fillfactor ]
+ [ ON { filegroup | DEFAULT } ]
+ ]
+ | FOREIGN KEY
+ [ ( column [ ,...n ] ) ]
+ REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( search_conditions )
+ }
+
+
+ */
+
+ /*
+ CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
+ ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
+ [ WITH < index_option > [ ,...n] ]
+ [ ON filegroup ]
+ < index_option > :: =
+ { PAD_INDEX |
+ FILLFACTOR = fillfactor |
+ IGNORE_DUP_KEY |
+ DROP_EXISTING |
+ STATISTICS_NORECOMPUTE |
+ SORT_IN_TEMPDB
+ }
+*/
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+ $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+
+ function _GetSize($ftype, $ty, $fsize, $fprec)
+ {
+ switch ($ftype) {
+ case 'INT':
+ case 'SMALLINT':
+ case 'TINYINT':
+ case 'BIGINT':
+ return $ftype;
+ }
+ if ($ty == 'T') return $ftype;
+ return parent::_GetSize($ftype, $ty, $fsize, $fprec);
+
+ }
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-mysql.inc.php b/vendor/adodb/adodb-php/datadict/datadict-mysql.inc.php
new file mode 100644
index 0000000..defb124
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-mysql.inc.php
@@ -0,0 +1,183 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_mysql extends ADODB_DataDict {
+ var $databaseType = 'mysql';
+ var $alterCol = ' MODIFY COLUMN';
+ var $alterTableAddIndex = true;
+ var $dropTable = 'DROP TABLE IF EXISTS %s'; // requires mysql 3.22 or later
+
+ var $dropIndex = 'DROP INDEX %s ON %s';
+ var $renameColumn = 'ALTER TABLE %s CHANGE COLUMN %s %s %s'; // needs column-definition!
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment;
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'STRING':
+ case 'CHAR':
+ case 'VARCHAR':
+ case 'TINYBLOB':
+ case 'TINYTEXT':
+ case 'ENUM':
+ case 'SET':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ case 'LONGTEXT':
+ case 'MEDIUMTEXT':
+ return 'X';
+
+ // php_mysql extension always returns 'blob' even if 'text'
+ // so we have to check whether binary...
+ case 'IMAGE':
+ case 'LONGBLOB':
+ case 'BLOB':
+ case 'MEDIUMBLOB':
+ return !empty($fieldobj->binary) ? 'B' : 'X';
+
+ case 'YEAR':
+ case 'DATE': return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP': return 'T';
+
+ case 'FLOAT':
+ case 'DOUBLE':
+ return 'F';
+
+ case 'INT':
+ case 'INTEGER': return $is_serial ? 'R' : 'I';
+ case 'TINYINT': return $is_serial ? 'R' : 'I1';
+ case 'SMALLINT': return $is_serial ? 'R' : 'I2';
+ case 'MEDIUMINT': return $is_serial ? 'R' : 'I4';
+ case 'BIGINT': return $is_serial ? 'R' : 'I8';
+ default: return 'N';
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+ case 'C': return 'VARCHAR';
+ case 'XL':return 'LONGTEXT';
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'VARCHAR';
+ case 'X2': return 'LONGTEXT';
+
+ case 'B': return 'LONGBLOB';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'DATETIME';
+ case 'L': return 'TINYINT';
+
+ case 'R':
+ case 'I4':
+ case 'I': return 'INTEGER';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($funsigned) $suffix .= ' UNSIGNED';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' AUTO_INCREMENT';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+ CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
+ [table_options] [select_statement]
+ create_definition:
+ col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
+ [PRIMARY KEY] [reference_definition]
+ or PRIMARY KEY (index_col_name,...)
+ or KEY [index_name] (index_col_name,...)
+ or INDEX [index_name] (index_col_name,...)
+ or UNIQUE [INDEX] [index_name] (index_col_name,...)
+ or FULLTEXT [INDEX] [index_name] (index_col_name,...)
+ or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
+ [reference_definition]
+ or CHECK (expr)
+ */
+
+ /*
+ CREATE [UNIQUE|FULLTEXT] INDEX index_name
+ ON tbl_name (col_name[(length)],... )
+ */
+
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ if ($this->alterTableAddIndex) $sql[] = "ALTER TABLE $tabname DROP INDEX $idxname";
+ else $sql[] = sprintf($this->dropIndex, $idxname, $tabname);
+
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ if (isset($idxoptions['FULLTEXT'])) {
+ $unique = ' FULLTEXT';
+ } elseif (isset($idxoptions['UNIQUE'])) {
+ $unique = ' UNIQUE';
+ } else {
+ $unique = '';
+ }
+
+ if ( is_array($flds) ) $flds = implode(', ',$flds);
+
+ if ($this->alterTableAddIndex) $s = "ALTER TABLE $tabname ADD $unique INDEX $idxname ";
+ else $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname;
+
+ $s .= ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-oci8.inc.php b/vendor/adodb/adodb-php/datadict/datadict-oci8.inc.php
new file mode 100644
index 0000000..bef8d61
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-oci8.inc.php
@@ -0,0 +1,300 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_oci8 extends ADODB_DataDict {
+
+ var $databaseType = 'oci8';
+ var $seqField = false;
+ var $seqPrefix = 'SEQ_';
+ var $dropTable = "DROP TABLE %s CASCADE CONSTRAINTS";
+ var $trigPrefix = 'TRIG_';
+ var $alterCol = ' MODIFY ';
+ var $typeX = 'VARCHAR(4000)';
+ var $typeXL = 'CLOB';
+
+ function MetaType($t, $len=-1, $fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'VARCHAR':
+ case 'VARCHAR2':
+ case 'CHAR':
+ case 'VARBINARY':
+ case 'BINARY':
+ if (isset($this) && $len <= $this->blobSize) return 'C';
+ return 'X';
+
+ case 'NCHAR':
+ case 'NVARCHAR2':
+ case 'NVARCHAR':
+ if (isset($this) && $len <= $this->blobSize) return 'C2';
+ return 'X2';
+
+ case 'NCLOB':
+ case 'CLOB':
+ return 'XL';
+
+ case 'LONG RAW':
+ case 'LONG VARBINARY':
+ case 'BLOB':
+ return 'B';
+
+ case 'TIMESTAMP':
+ return 'TS';
+
+ case 'DATE':
+ return 'T';
+
+ case 'INT':
+ case 'SMALLINT':
+ case 'INTEGER':
+ return 'I';
+
+ default:
+ return 'N';
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'X': return $this->typeX;
+ case 'XL': return $this->typeXL;
+
+ case 'C2': return 'NVARCHAR2';
+ case 'X2': return 'NVARCHAR2(4000)';
+
+ case 'B': return 'BLOB';
+
+ case 'TS':
+ return 'TIMESTAMP';
+
+ case 'D':
+ case 'T': return 'DATE';
+ case 'L': return 'NUMBER(1)';
+ case 'I1': return 'NUMBER(3)';
+ case 'I2': return 'NUMBER(5)';
+ case 'I':
+ case 'I4': return 'NUMBER(10)';
+
+ case 'I8': return 'NUMBER(20)';
+ case 'F': return 'NUMBER';
+ case 'N': return 'NUMBER';
+ case 'R': return 'NUMBER(20)';
+ default:
+ return $meta;
+ }
+ }
+
+ function CreateDatabase($dbname, $options=false)
+ {
+ $options = $this->_Options($options);
+ $password = isset($options['PASSWORD']) ? $options['PASSWORD'] : 'tiger';
+ $tablespace = isset($options["TABLESPACE"]) ? " DEFAULT TABLESPACE ".$options["TABLESPACE"] : '';
+ $sql[] = "CREATE USER ".$dbname." IDENTIFIED BY ".$password.$tablespace;
+ $sql[] = "GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO $dbname";
+
+ return $sql;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname ADD (";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+
+ $s .= implode(', ',$f).')';
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ $tabname = $this->TableName($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname MODIFY(";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f).')';
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v);
+
+ $sql = array();
+ $s = "ALTER TABLE $tabname DROP(";
+ $s .= implode(', ',$flds).') CASCADE CONSTRAINTS';
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function _DropAutoIncrement($t)
+ {
+ if (strpos($t,'.') !== false) {
+ $tarr = explode('.',$t);
+ return "drop sequence ".$tarr[0].".seq_".$tarr[1];
+ }
+ return "drop sequence seq_".$t;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+
+ if ($fdefault == "''" && $fnotnull) {// this is null in oracle
+ $fnotnull = false;
+ if ($this->debug) ADOConnection::outp("NOT NULL and DEFAULT='' illegal in Oracle");
+ }
+
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+
+ if ($fautoinc) $this->seqField = $fname;
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+
+ return $suffix;
+ }
+
+/*
+CREATE or replace TRIGGER jaddress_insert
+before insert on jaddress
+for each row
+begin
+select seqaddress.nextval into :new.A_ID from dual;
+end;
+*/
+ function _Triggers($tabname,$tableoptions)
+ {
+ if (!$this->seqField) return array();
+
+ if ($this->schema) {
+ $t = strpos($tabname,'.');
+ if ($t !== false) $tab = substr($tabname,$t+1);
+ else $tab = $tabname;
+ $seqname = $this->schema.'.'.$this->seqPrefix.$tab;
+ $trigname = $this->schema.'.'.$this->trigPrefix.$this->seqPrefix.$tab;
+ } else {
+ $seqname = $this->seqPrefix.$tabname;
+ $trigname = $this->trigPrefix.$seqname;
+ }
+
+ if (strlen($seqname) > 30) {
+ $seqname = $this->seqPrefix.uniqid('');
+ } // end if
+ if (strlen($trigname) > 30) {
+ $trigname = $this->trigPrefix.uniqid('');
+ } // end if
+
+ if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
+ $seqCache = '';
+ if (isset($tableoptions['SEQUENCE_CACHE'])){$seqCache = $tableoptions['SEQUENCE_CACHE'];}
+ $seqIncr = '';
+ if (isset($tableoptions['SEQUENCE_INCREMENT'])){$seqIncr = ' INCREMENT BY '.$tableoptions['SEQUENCE_INCREMENT'];}
+ $seqStart = '';
+ if (isset($tableoptions['SEQUENCE_START'])){$seqIncr = ' START WITH '.$tableoptions['SEQUENCE_START'];}
+ $sql[] = "CREATE SEQUENCE $seqname $seqStart $seqIncr $seqCache";
+ $sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW WHEN (NEW.$this->seqField IS NULL OR NEW.$this->seqField = 0) BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;";
+
+ $this->seqField = false;
+ return $sql;
+ }
+
+ /*
+ CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
+ [table_options] [select_statement]
+ create_definition:
+ col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
+ [PRIMARY KEY] [reference_definition]
+ or PRIMARY KEY (index_col_name,...)
+ or KEY [index_name] (index_col_name,...)
+ or INDEX [index_name] (index_col_name,...)
+ or UNIQUE [INDEX] [index_name] (index_col_name,...)
+ or FULLTEXT [INDEX] [index_name] (index_col_name,...)
+ or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
+ [reference_definition]
+ or CHECK (expr)
+ */
+
+
+
+ function _IndexSQL($idxname, $tabname, $flds,$idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ if (isset($idxoptions['BITMAP'])) {
+ $unique = ' BITMAP';
+ } elseif (isset($idxoptions['UNIQUE'])) {
+ $unique = ' UNIQUE';
+ } else {
+ $unique = '';
+ }
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ if (isset($idxoptions['oci8']))
+ $s .= $idxoptions['oci8'];
+
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ function GetCommentSQL($table,$col)
+ {
+ $table = $this->connection->qstr($table);
+ $col = $this->connection->qstr($col);
+ return "select comments from USER_COL_COMMENTS where TABLE_NAME=$table and COLUMN_NAME=$col";
+ }
+
+ function SetCommentSQL($table,$col,$cmt)
+ {
+ $cmt = $this->connection->qstr($cmt);
+ return "COMMENT ON COLUMN $table.$col IS $cmt";
+ }
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-postgres.inc.php b/vendor/adodb/adodb-php/datadict/datadict-postgres.inc.php
new file mode 100644
index 0000000..b1a9355
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-postgres.inc.php
@@ -0,0 +1,484 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_postgres extends ADODB_DataDict {
+
+ var $databaseType = 'postgres';
+ var $seqField = false;
+ var $seqPrefix = 'SEQ_';
+ var $addCol = ' ADD COLUMN';
+ var $quote = '"';
+ var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
+ var $dropTable = 'DROP TABLE %s CASCADE';
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ $is_serial = is_object($fieldobj) && !empty($fieldobj->primary_key) && !empty($fieldobj->unique) &&
+ !empty($fieldobj->has_default) && substr($fieldobj->default_value,0,8) == 'nextval(';
+
+ switch (strtoupper($t)) {
+ case 'INTERVAL':
+ case 'CHAR':
+ case 'CHARACTER':
+ case 'VARCHAR':
+ case 'NAME':
+ case 'BPCHAR':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ return 'X';
+
+ case 'IMAGE': // user defined type
+ case 'BLOB': // user defined type
+ case 'BIT': // This is a bit string, not a single bit, so don't return 'L'
+ case 'VARBIT':
+ case 'BYTEA':
+ return 'B';
+
+ case 'BOOL':
+ case 'BOOLEAN':
+ return 'L';
+
+ case 'DATE':
+ return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP':
+ case 'TIMESTAMPTZ':
+ return 'T';
+
+ case 'INTEGER': return !$is_serial ? 'I' : 'R';
+ case 'SMALLINT':
+ case 'INT2': return !$is_serial ? 'I2' : 'R';
+ case 'INT4': return !$is_serial ? 'I4' : 'R';
+ case 'BIGINT':
+ case 'INT8': return !$is_serial ? 'I8' : 'R';
+
+ case 'OID':
+ case 'SERIAL':
+ return 'R';
+
+ case 'FLOAT4':
+ case 'FLOAT8':
+ case 'DOUBLE PRECISION':
+ case 'REAL':
+ return 'F';
+
+ default:
+ return 'N';
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'VARCHAR';
+ case 'X2': return 'TEXT';
+
+ case 'B': return 'BYTEA';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'BOOLEAN';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'INT2';
+ case 'I4': return 'INT4';
+ case 'I8': return 'INT8';
+
+ case 'F': return 'FLOAT8';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+ /**
+ * Adding a new Column
+ *
+ * reimplementation of the default function as postgres does NOT allow to set the default in the same statement
+ *
+ * @param string $tabname table-name
+ * @param string $flds column-names and types for the changed columns
+ * @return array with SQL strings
+ */
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ $not_null = false;
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
+ foreach($lines as $v) {
+ if (($not_null = preg_match('/NOT NULL/i',$v))) {
+ $v = preg_replace('/NOT NULL/i','',$v);
+ }
+ if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) {
+ list(,$colname,$default) = $matches;
+ $sql[] = $alter . str_replace('DEFAULT '.$default,'',$v);
+ $sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default;
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
+ } else {
+ $sql[] = $alter . $v;
+ }
+ if ($not_null) {
+ list($colname) = explode(' ',$v);
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
+ }
+ }
+ return $sql;
+ }
+
+
+ function DropIndexSQL ($idxname, $tabname = NULL)
+ {
+ return array(sprintf($this->dropIndex, $this->TableName($idxname), $this->TableName($tabname)));
+ }
+
+ /**
+ * Change the definition of one column
+ *
+ * Postgres can't do that on it's own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
+ * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ /*
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if (!$tableflds) {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
+ return array();
+ }
+ return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
+ }*/
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ // Check if alter single column datatype available - works with 8.0+
+ $has_alter_column = 8.0 <= (float) @$this->serverInfo['version'];
+
+ if ($has_alter_column) {
+ $tabname = $this->TableName($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $set_null = false;
+ foreach($lines as $v) {
+ $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+ if ($not_null = preg_match('/NOT NULL/i',$v)) {
+ $v = preg_replace('/NOT NULL/i','',$v);
+ }
+ // this next block doesn't work - there is no way that I can see to
+ // explicitly ask a column to be null using $flds
+ else if ($set_null = preg_match('/NULL/i',$v)) {
+ // if they didn't specify not null, see if they explicitely asked for null
+ // Lookbehind pattern covers the case 'fieldname NULL datatype DEFAULT NULL'
+ // only the first NULL should be removed, not the one specifying
+ // the default value
+ $v = preg_replace('/(?<!DEFAULT)\sNULL/i','',$v);
+ }
+
+ if (preg_match('/^([^ ]+) .*DEFAULT (\'[^\']+\'|\"[^\"]+\"|[^ ]+)/',$v,$matches)) {
+ $existing = $this->MetaColumns($tabname);
+ list(,$colname,$default) = $matches;
+ $alter .= $colname;
+ if ($this->connection) {
+ $old_coltype = $this->connection->MetaType($existing[strtoupper($colname)]);
+ }
+ else {
+ $old_coltype = $t;
+ }
+ $v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
+ $t = trim(str_replace('DEFAULT '.$default,'',$v));
+
+ // Type change from bool to int
+ if ( $old_coltype == 'L' && $t == 'INTEGER' ) {
+ $sql[] = $alter . ' DROP DEFAULT';
+ $sql[] = $alter . " TYPE $t USING ($colname::BOOL)::INT";
+ $sql[] = $alter . " SET DEFAULT $default";
+ }
+ // Type change from int to bool
+ else if ( $old_coltype == 'I' && $t == 'BOOLEAN' ) {
+ if( strcasecmp('NULL', trim($default)) != 0 ) {
+ $default = $this->connection->qstr($default);
+ }
+ $sql[] = $alter . ' DROP DEFAULT';
+ $sql[] = $alter . " TYPE $t USING CASE WHEN $colname = 0 THEN false ELSE true END";
+ $sql[] = $alter . " SET DEFAULT $default";
+ }
+ // Any other column types conversion
+ else {
+ $sql[] = $alter . " TYPE $t";
+ $sql[] = $alter . " SET DEFAULT $default";
+ }
+
+ }
+ else {
+ // drop default?
+ preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches);
+ list (,$colname,$rest) = $matches;
+ $alter .= $colname;
+ $sql[] = $alter . ' TYPE ' . $rest;
+ }
+
+# list($colname) = explode(' ',$v);
+ if ($not_null) {
+ // this does not error out if the column is already not null
+ $sql[] = $alter . ' SET NOT NULL';
+ }
+ if ($set_null) {
+ // this does not error out if the column is already null
+ $sql[] = $alter . ' DROP NOT NULL';
+ }
+ }
+ return $sql;
+ }
+
+ // does not have alter column
+ if (!$tableflds) {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
+ return array();
+ }
+ return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
+ }
+
+ /**
+ * Drop one column
+ *
+ * Postgres < 7.3 can't do that on it's own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
+ * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
+ if (!$has_drop_column && !$tableflds) {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
+ return array();
+ }
+ if ($has_drop_column) {
+ return ADODB_DataDict::DropColumnSQL($tabname, $flds);
+ }
+ return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
+ }
+
+ /**
+ * Save the content into a temp. table, drop and recreate the original table and copy the content back in
+ *
+ * We also take care to set the values of the sequenz and recreate the indexes.
+ * All this is done in a transaction, to not loose the content of the table, if something went wrong!
+ * @internal
+ * @param string $tabname table-name
+ * @param string $dropflds column-names to drop
+ * @param string $tableflds complete defintion of the new table, eg. for postgres
+ * @param array/string $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
+ {
+ if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
+ $copyflds = array();
+ foreach($this->MetaColumns($tabname) as $fld) {
+ if (!$dropflds || !in_array($fld->name,$dropflds)) {
+ // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
+ if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
+ in_array($fld->type,array('varchar','char','text','bytea'))) {
+ $copyflds[] = "to_number($fld->name,'S9999999999999D99')";
+ } else {
+ $copyflds[] = $fld->name;
+ }
+ // identify the sequence name and the fld its on
+ if ($fld->primary_key && $fld->has_default &&
+ preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) {
+ $seq_name = $matches[1];
+ $seq_fld = $fld->name;
+ }
+ }
+ }
+ $copyflds = implode(', ',$copyflds);
+
+ $tempname = $tabname.'_tmp';
+ $aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table
+ $aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname";
+ $aSql = array_merge($aSql,$this->DropTableSQL($tabname));
+ $aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
+ $aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
+ if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again
+ $seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence
+ $aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
+ }
+ $aSql[] = "DROP TABLE $tempname";
+ // recreate the indexes, if they not contain one of the droped columns
+ foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
+ {
+ if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
+ $aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
+ $idx_data['unique'] ? array('UNIQUE') : False));
+ }
+ }
+ $aSql[] = 'COMMIT';
+ return $aSql;
+ }
+
+ function DropTableSQL($tabname)
+ {
+ $sql = ADODB_DataDict::DropTableSQL($tabname);
+
+ $drop_seq = $this->_DropAutoIncrement($tabname);
+ if ($drop_seq) $sql[] = $drop_seq;
+
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ if ($fautoinc) {
+ $ftype = 'SERIAL';
+ return '';
+ }
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ // search for a sequece for the given table (asumes the seqence-name contains the table-name!)
+ // if yes return sql to drop it
+ // this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!!
+ function _DropAutoIncrement($tabname)
+ {
+ $tabname = $this->connection->quote('%'.$tabname.'%');
+
+ $seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
+
+ // check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly
+ if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) {
+ return False;
+ }
+ return "DROP SEQUENCE ".$seq;
+ }
+
+ function RenameTableSQL($tabname,$newname)
+ {
+ if (!empty($this->schema)) {
+ $rename_from = $this->TableName($tabname);
+ $schema_save = $this->schema;
+ $this->schema = false;
+ $rename_to = $this->TableName($newname);
+ $this->schema = $schema_save;
+ return array (sprintf($this->renameTable, $rename_from, $rename_to));
+ }
+
+ return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
+ }
+
+ /*
+ CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
+ { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ]
+ | table_constraint } [, ... ]
+ )
+ [ INHERITS ( parent_table [, ... ] ) ]
+ [ WITH OIDS | WITHOUT OIDS ]
+ where column_constraint is:
+ [ CONSTRAINT constraint_name ]
+ { NOT NULL | NULL | UNIQUE | PRIMARY KEY |
+ CHECK (expression) |
+ REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL ]
+ [ ON DELETE action ] [ ON UPDATE action ] }
+ [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
+ and table_constraint is:
+ [ CONSTRAINT constraint_name ]
+ { UNIQUE ( column_name [, ... ] ) |
+ PRIMARY KEY ( column_name [, ... ] ) |
+ CHECK ( expression ) |
+ FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]
+ [ MATCH FULL | MATCH PARTIAL ] [ ON DELETE action ] [ ON UPDATE action ] }
+ [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
+ */
+
+
+ /*
+ CREATE [ UNIQUE ] INDEX index_name ON table
+[ USING acc_method ] ( column [ ops_name ] [, ...] )
+[ WHERE predicate ]
+CREATE [ UNIQUE ] INDEX index_name ON table
+[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] )
+[ WHERE predicate ]
+ */
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+
+ $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
+
+ if (isset($idxoptions['HASH']))
+ $s .= 'USING HASH ';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s .= '(' . $flds . ')';
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ function _GetSize($ftype, $ty, $fsize, $fprec)
+ {
+ if (strlen($fsize) && $ty != 'X' && $ty != 'B' && $ty != 'I' && strpos($ftype,'(') === false) {
+ $ftype .= "(".$fsize;
+ if (strlen($fprec)) $ftype .= ",".$fprec;
+ $ftype .= ')';
+ }
+ return $ftype;
+ }
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-sapdb.inc.php b/vendor/adodb/adodb-php/datadict/datadict-sapdb.inc.php
new file mode 100644
index 0000000..794edf7
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-sapdb.inc.php
@@ -0,0 +1,122 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+ Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_sapdb extends ADODB_DataDict {
+
+ var $databaseType = 'sapdb';
+ var $seqField = false;
+ var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'LONG';
+
+ case 'C2': return 'VARCHAR UNICODE';
+ case 'X2': return 'LONG UNICODE';
+
+ case 'B': return 'LONG';
+
+ case 'D': return 'DATE';
+ case 'TS':
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'BOOLEAN';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'FIXED(3)';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'FIXED(20)';
+
+ case 'F': return 'FLOAT(38)';
+ case 'N': return 'FIXED';
+ default:
+ return $meta;
+ }
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ static $maxdb_type2adodb = array(
+ 'VARCHAR' => 'C',
+ 'CHARACTER' => 'C',
+ 'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
+ 'DATE' => 'D',
+ 'TIMESTAMP' => 'T',
+ 'BOOLEAN' => 'L',
+ 'INTEGER' => 'I4',
+ 'SMALLINT' => 'I2',
+ 'FLOAT' => 'F',
+ 'FIXED' => 'N',
+ );
+ $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
+
+ // convert integer-types simulated with fixed back to integer
+ if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
+ $type = $len == 20 ? 'I8' : 'I1';
+ }
+ if ($fieldobj->auto_increment) $type = 'R';
+
+ return $type;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($funsigned) $suffix .= ' UNSIGNED';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
+ elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
+ }
+
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ foreach($flds as $k => $v) {
+ $flds[$k] = $this->NameQuote($v);
+ }
+ return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
+ }
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-sqlite.inc.php b/vendor/adodb/adodb-php/datadict/datadict-sqlite.inc.php
new file mode 100644
index 0000000..fc994fe
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-sqlite.inc.php
@@ -0,0 +1,90 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+ SQLite datadict Andrei Besleaga
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_sqlite extends ADODB_DataDict {
+ var $databaseType = 'sqlite';
+ var $seqField = false;
+ var $addCol=' ADD COLUMN';
+ var $dropTable = 'DROP TABLE IF EXISTS %s';
+ var $dropIndex = 'DROP INDEX IF EXISTS %s';
+ var $renameTable = 'ALTER TABLE %s RENAME TO %s';
+
+
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+ case 'C': return 'VARCHAR'; // TEXT , TEXT affinity
+ case 'XL':return 'LONGTEXT'; // TEXT , TEXT affinity
+ case 'X': return 'TEXT'; // TEXT , TEXT affinity
+
+ case 'C2': return 'VARCHAR'; // TEXT , TEXT affinity
+ case 'X2': return 'LONGTEXT'; // TEXT , TEXT affinity
+
+ case 'B': return 'LONGBLOB'; // TEXT , NONE affinity , BLOB
+
+ case 'D': return 'DATE'; // NUMERIC , NUMERIC affinity
+ case 'T': return 'DATETIME'; // NUMERIC , NUMERIC affinity
+ case 'L': return 'TINYINT'; // NUMERIC , INTEGER affinity
+
+ case 'R':
+ case 'I4':
+ case 'I': return 'INTEGER'; // NUMERIC , INTEGER affinity
+ case 'I1': return 'TINYINT'; // NUMERIC , INTEGER affinity
+ case 'I2': return 'SMALLINT'; // NUMERIC , INTEGER affinity
+ case 'I8': return 'BIGINT'; // NUMERIC , INTEGER affinity
+
+ case 'F': return 'DOUBLE'; // NUMERIC , REAL affinity
+ case 'N': return 'NUMERIC'; // NUMERIC , NUMERIC affinity
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($funsigned) $suffix .= ' UNSIGNED';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' AUTOINCREMENT';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported natively by SQLite");
+ return array();
+ }
+
+ function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported natively by SQLite");
+ return array();
+ }
+
+ function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
+ {
+ if ($this->debug) ADOConnection::outp("RenameColumnSQL not supported natively by SQLite");
+ return array();
+ }
+
+}
diff --git a/vendor/adodb/adodb-php/datadict/datadict-sybase.inc.php b/vendor/adodb/adodb-php/datadict/datadict-sybase.inc.php
new file mode 100644
index 0000000..87654ff
--- /dev/null
+++ b/vendor/adodb/adodb-php/datadict/datadict-sybase.inc.php
@@ -0,0 +1,230 @@
+<?php
+
+/**
+ @version v5.20.14 06-Jan-2019
+ @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_sybase extends ADODB_DataDict {
+ var $databaseType = 'sybase';
+
+ var $dropIndex = 'DROP INDEX %2$s.%1$s';
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+
+ case 'INT':
+ case 'INTEGER': return 'I';
+ case 'BIT':
+ case 'TINYINT': return 'I1';
+ case 'SMALLINT': return 'I2';
+ case 'BIGINT': return 'I8';
+
+ case 'REAL':
+ case 'FLOAT': return 'F';
+ default: return parent::MetaType($t,$len,$fieldobj);
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'NTEXT';
+
+ case 'B': return 'IMAGE';
+
+ case 'D': return 'DATETIME';
+ case 'TS':
+ case 'T': return 'DATETIME';
+ case 'L': return 'BIT';
+
+ case 'I': return 'INT';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'REAL';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname $this->addCol";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ foreach($lines as $v) {
+ $sql[] = "ALTER TABLE $tabname $this->alterCol $v";
+ }
+
+ return $sql;
+ }
+
+ function DropColumnSQL($tabname, $flds, $tableflds='', $tableoptions='')
+ {
+ $tabname = $this->TableName($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ $f = array();
+ $s = "ALTER TABLE $tabname";
+ foreach($flds as $v) {
+ $f[] = "\n$this->dropCol ".$this->NameQuote($v);
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' DEFAULT AUTOINCREMENT';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ else if ($suffix == '') $suffix .= ' NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+CREATE TABLE
+ [ database_name.[ owner ] . | owner. ] table_name
+ ( { < column_definition >
+ | column_name AS computed_column_expression
+ | < table_constraint > ::= [ CONSTRAINT constraint_name ] }
+
+ | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
+ )
+
+[ ON { filegroup | DEFAULT } ]
+[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
+
+< column_definition > ::= { column_name data_type }
+ [ COLLATE < collation_name > ]
+ [ [ DEFAULT constant_expression ]
+ | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
+ ]
+ [ ROWGUIDCOL]
+ [ < column_constraint > ] [ ...n ]
+
+< column_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ NULL | NOT NULL ]
+ | [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ [ WITH FILLFACTOR = fillfactor ]
+ [ON {filegroup | DEFAULT} ] ]
+ ]
+ | [ [ FOREIGN KEY ]
+ REFERENCES ref_table [ ( ref_column ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( logical_expression )
+ }
+
+< table_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ { ( column [ ASC | DESC ] [ ,...n ] ) }
+ [ WITH FILLFACTOR = fillfactor ]
+ [ ON { filegroup | DEFAULT } ]
+ ]
+ | FOREIGN KEY
+ [ ( column [ ,...n ] ) ]
+ REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( search_conditions )
+ }
+
+
+ */
+
+ /*
+ CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
+ ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
+ [ WITH < index_option > [ ,...n] ]
+ [ ON filegroup ]
+ < index_option > :: =
+ { PAD_INDEX |
+ FILLFACTOR = fillfactor |
+ IGNORE_DUP_KEY |
+ DROP_EXISTING |
+ STATISTICS_NORECOMPUTE |
+ SORT_IN_TEMPDB
+ }
+*/
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+ $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+}