diff options
| author | Mark Newnham <mark@newnhams.com> | 2021-04-06 20:01:42 -0600 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2021-08-22 11:17:48 +0200 |
| commit | 941b10472e3307661415420f8a6cf2085a0d6c71 (patch) | |
| tree | e282dedc758a9483ca6608a30c15d644f40e7367 | |
| parent | f110367c375c9f184cae2a7884321bf29688d3b2 (diff) | |
| download | adodb-941b10472e3307661415420f8a6cf2085a0d6c71.tar.gz adodb-941b10472e3307661415420f8a6cf2085a0d6c71.tar.bz2 adodb-941b10472e3307661415420f8a6cf2085a0d6c71.zip | |
add basic support for column manipulation in the data dictionary
| -rw-r--r-- | datadict/datadict-firebird.inc.php | 38 | ||||
| -rw-r--r-- | drivers/adodb-firebird.inc.php | 45 |
2 files changed, 36 insertions, 47 deletions
diff --git a/datadict/datadict-firebird.inc.php b/datadict/datadict-firebird.inc.php index b2278ee0..05332f7b 100644 --- a/datadict/datadict-firebird.inc.php +++ b/datadict/datadict-firebird.inc.php @@ -209,27 +209,39 @@ end; } /** - * Change the definition of one column - * - * As some DBM's can't do that on there own, you need to supply the complete definition 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 definition of the new table, eg. for postgres, default '' - * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' - * @return array with SQL strings - */ - function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + * Change the definition of one column + * + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' + * @param array/string $tableoptions='' options for the new table + * + * @return array with SQL strings + */ + public function alterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') { $tabname = $this->TableName ($tabname); $sql = array(); list($lines,$pkey,$idxs) = $this->_GenFields($flds); // genfields can return FALSE at times - if ($lines == null) $lines = array(); + + if ($lines == null) + $lines = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; - foreach($lines as $v) { + + foreach($lines as $v) + { + /* + * The type must be preceded by the keyword 'TYPE' + */ + $vExplode = explode(' ',$v); + $vExplode = array_filter($vExplode); + array_splice($vExplode,1,0,array('TYPE')); + $v = implode(' ',$vExplode); $sql[] = $alter . $v; } + if (is_array($idxs)) { foreach($idxs as $idx => $idxdef) { $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php index f1dc6bdc..45022c69 100644 --- a/drivers/adodb-firebird.inc.php +++ b/drivers/adodb-firebird.inc.php @@ -1153,34 +1153,7 @@ class ADORecordset_firebird extends ADORecordSet return false; } - function x_fetch($ignore_fields=false) - { - if ($this->fetchMode & ADODB_FETCH_ASSOC) { - if ($this->fetchMode & ADODB_FETCH_NUM) - $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH); - else - $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC); - - 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); - - } - } - else - $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC); - - if (!$this->fields) - return false; - - return $this->fields; - } - - function _fetch() + public function _fetch() { $localNumeric = true;; @@ -1205,7 +1178,7 @@ class ADORecordset_firebird extends ADORecordSet } else /* - * Humeric result + * Numeric result */ $f = @fbird_fetch_row($this->_queryID); @@ -1317,7 +1290,7 @@ class ADORecordset_firebird extends ADORecordSet return @fbird_free_result($this->_queryID); } - function MetaType($t,$len=-1,$fieldobj=false) + public function metaType($t,$len=-1,$fieldobj=false) { if (is_object($t)) { $fieldobj = $t; @@ -1344,15 +1317,19 @@ class ADORecordset_firebird extends ADORecordSet return 'B'; case 'TIMESTAMP': - case 'DATE': return 'D'; - case 'TIME': return 'T'; + 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; + case 'INTEGER': + return 'I'; + default: + return ADODB_DEFAULT_METATYPE; } } |
