forked from extern/egroupware
got updates working again for MaxDB, MySql and MsSql (untested). Now I need to start working on postgres.
This commit is contained in:
parent
0a566e4635
commit
4dae67c9c0
@ -162,10 +162,12 @@ class ADODB_DataDict {
|
||||
var $connection;
|
||||
var $debug = false;
|
||||
var $dropTable = 'DROP TABLE %s';
|
||||
var $renameTable = 'RENAME TABLE %s TO %s';
|
||||
var $dropIndex = 'DROP INDEX %s';
|
||||
var $addCol = ' ADD';
|
||||
var $alterCol = ' ALTER COLUMN';
|
||||
var $dropCol = ' DROP COLUMN';
|
||||
var $renameCol = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default)
|
||||
var $nameRegex = '\w';
|
||||
var $schema = false;
|
||||
var $serverInfo = array();
|
||||
@ -350,6 +352,18 @@ class ADODB_DataDict {
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// $flds is only used for mysql so far
|
||||
function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if ($flds) {
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
list(,$first) = each($lines);
|
||||
list(,$column_def) = split("[\t ]+",$first,2);
|
||||
}
|
||||
return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
@ -367,6 +381,11 @@ class ADODB_DataDict {
|
||||
return array (sprintf($this->dropTable, $this->TableName($tabname)));
|
||||
}
|
||||
|
||||
function RenameTableSQL($tabname,$newname)
|
||||
{
|
||||
return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
|
||||
}
|
||||
|
||||
/*
|
||||
Generate the SQL to create table. Returns an array of sql strings.
|
||||
*/
|
||||
|
@ -17,6 +17,8 @@ class ADODB2_mssql extends ADODB_DataDict {
|
||||
var $databaseType = 'mssql';
|
||||
|
||||
var $dropIndex = 'DROP INDEX %2$s.%1$s';
|
||||
var $renameTable = "EXEC sp_rename '%1','%2'";
|
||||
var $renameColumn = "EXEC sp_rename '%1.%2','%3'";
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ class ADODB2_mysql extends ADODB_DataDict {
|
||||
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)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ class ADODB2_postgres extends ADODB_DataDict {
|
||||
var $seqPrefix = 'SEQ_';
|
||||
var $addCol = ' ADD COLUMN';
|
||||
var $quote = '"';
|
||||
var $renameTable = 'ALTER TABLE %s RENAME TO %s';
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'sapdb';
|
||||
var $seqField = false;
|
||||
var $renameCol = 'RENAME COLUMN %s.%s TO %s';
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
@ -48,15 +49,6 @@ class ADODB2_sapdb extends ADODB_DataDict {
|
||||
}
|
||||
}
|
||||
|
||||
function CreateTableSQL($tabname, $flds, $tableoptions=false)
|
||||
{
|
||||
$sql = ADODB_DataDict::CreateTableSQL($tabname, $flds, $tableoptions);
|
||||
|
||||
echo "<pre>".print_r($sql,true)."</pre>\n";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
@ -92,7 +84,7 @@ class ADODB2_sapdb extends ADODB_DataDict {
|
||||
foreach($flds as $k => $v) {
|
||||
$flds[$k] = $this->NameQuote($v);
|
||||
}
|
||||
return array( 'ALTER TABLE ' . $tabname . 'DROP (' . implode(',',$flds) . ')' );
|
||||
return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(',',$flds) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,15 @@ class ADODB_SAPDB extends ADODB_odbc {
|
||||
$this->ADODB_odbc();
|
||||
}
|
||||
|
||||
// ToDo: retrive column-names and use $primary !!!
|
||||
function &MetaIndexes ($table, $primary = FALSE)
|
||||
{
|
||||
if ($primary) {
|
||||
return array(
|
||||
'SYSPRIMARYKEYINDEX' => array(
|
||||
'unique' => True, // by definition
|
||||
'columns' => $this->MetaPrimaryKeys($table),
|
||||
));
|
||||
}
|
||||
$table = $this->Quote(strtoupper($table));
|
||||
$sql = "SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ".
|
||||
" WHERE TABLENAME=$table".
|
||||
|
Loading…
Reference in New Issue
Block a user