summaryrefslogtreecommitdiff
path: root/datadict
diff options
context:
space:
mode:
authorMark Newnham <mark@newnhams.com>2018-07-29 17:08:48 -0600
committerMark Newnham <mark@newnhams.com>2018-07-29 17:08:48 -0600
commit7eef62a30d39f16b483e64725e5575f68545c695 (patch)
treee1d61aea6a9b11b818dec462a496ac5d5916eab4 /datadict
parenta505c0b1e75097b2f419aa743b0727e9e0a18e4b (diff)
downloadadodb-7eef62a30d39f16b483e64725e5575f68545c695.tar.gz
adodb-7eef62a30d39f16b483e64725e5575f68545c695.tar.bz2
adodb-7eef62a30d39f16b483e64725e5575f68545c695.zip
This release of the IBM DB2 driver is a full rewrite, based on the DB2
native mode client, instead of the ODBC based one used previously. It encompasses the following changes: 1. All of the missing data dictionary functions have been added. 2. Proper binding of parameters to queries. 3. Support for stored procedures. 4. Full support for specific table casing, via a new method, setTableCase(). 5. Support for the setConnectionParameter() method, allowing use of elements such as CURSOR and trustedcontext 6. Connections via both catalogued and uncatalogued connections. 7. Support for sequences 8. The option $uCaseTables is no longer supported 9. The performance monitor is currently out of operation due to changes in the DB2 system tables The driver has been tested on PHP version 7.1, and is not supported on ADOdb versions less than 5.21
Diffstat (limited to 'datadict')
-rw-r--r--datadict/datadict-db2.inc.php76
1 files changed, 65 insertions, 11 deletions
diff --git a/datadict/datadict-db2.inc.php b/datadict/datadict-db2.inc.php
index 69c40986..93bf79b7 100644
--- a/datadict/datadict-db2.inc.php
+++ b/datadict/datadict-db2.inc.php
@@ -1,5 +1,4 @@
<?php
-
/**
@version v5.21.0-dev ??-???-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@@ -18,6 +17,7 @@ class ADODB2_db2 extends ADODB_DataDict {
var $databaseType = 'db2';
var $seqField = false;
+ var $dropCol = 'ALTER TABLE %s DROP COLUMN %s';
function ActualType($meta)
{
@@ -60,20 +60,66 @@ class ADODB2_db2 extends ADODB_DataDict {
return $suffix;
}
- function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ function alterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
- if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
- return array();
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey,$idxs) = $this->_GenFields($flds);
+ // genfields can return FALSE at times
+ if ($lines == null) $lines = array();
+ $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+
+ $dataTypeWords = array('SET','DATA','TYPE');
+
+ foreach($lines as $v)
+ {
+ /*
+ * We must now post-process the line to insert the 'SET DATA TYPE'
+ * text into the alter statement
+ */
+ $e = explode(' ',$v);
+
+ array_splice($e,1,0,$dataTypeWords);
+
+ $v = implode(' ',$e);
+
+ $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;
}
- function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+
+ function dropColumnSql($tabname, $flds, $tableflds='',$tableoptions='')
{
- if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
- return array();
+
+
+ $tabname = $this->connection->getMetaCasedValue($tabname);
+ $flds = $this->connection->getMetaCasedValue($flds);
+
+ if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_NATIVE )
+ {
+ /*
+ * METACASE_NATIVE
+ */
+ $tabname = $this->connection->nameQuote . $tabname . $this->connection->nameQuote;
+ $flds = $this->connection->nameQuote . $flds . $this->connection->nameQuote;
+ }
+ $sql = sprintf($this->dropCol,$tabname,$flds);
+ return (array)$sql;
+
}
+
- function ChangeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFlds=false)
+ function changeTableSQL($tablename, $flds, $tableoptions = false, $dropOldFields=false)
{
/**
@@ -85,17 +131,25 @@ class ADODB2_db2 extends ADODB_DataDict {
$validTypes = array("CHAR","VARC");
$invalidTypes = array("BIGI","BLOB","CLOB","DATE", "DECI","DOUB", "INTE", "REAL","SMAL", "TIME");
// check table exists
- $cols = $this->MetaColumns($tablename);
+
+
+ $cols = $this->metaColumns($tablename);
if ( empty($cols)) {
- return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+ return $this->createTableSQL($tablename, $flds, $tableoptions);
}
// already exists, alter table instead
list($lines,$pkey) = $this->_GenFields($flds);
- $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+ $alter = 'ALTER TABLE ' . $this->tableName($tablename);
$sql = array();
foreach ( $lines as $id => $v ) {
+ /*
+ * If the metaCasing was NATIVE the col returned with nameQuotes
+ * around the field. We need to remove this for the metaColumn
+ * match
+ */
+ $id = str_replace($this->connection->nameQuote,'',$id);
if ( isset($cols[$id]) && is_object($cols[$id]) ) {
/**
If the first field of $v is the fieldname, and