2001-01-02 09:22:36 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - Setup *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
class phpgw_schema_proc_array
|
|
|
|
{
|
|
|
|
var $m_sStatementTerminator;
|
|
|
|
|
|
|
|
function phpgw_schema_proc_array()
|
|
|
|
{
|
|
|
|
$this->m_sStatementTerminator = ";";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a type suitable for DDL abstracted array
|
2001-02-11 00:08:52 +01:00
|
|
|
function TranslateType($sType, $iPrecision = 0, $iScale = 0, &$sTranslated)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
$sTranslated = $sType;
|
|
|
|
return (strlen($sTranslated) > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function TranslateDefault($sDefault)
|
|
|
|
{
|
|
|
|
return $sDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetPKSQL($sFields)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetUCSQL($sFields)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function _GetColumns($oProc, &$aTables, $sTableName, &$sColumns, $sDropColumn = "")
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
$sColumns = "";
|
2001-02-11 00:08:52 +01:00
|
|
|
while (list($sName, $aJunk) = each($aTables[$sTableName]["fd"]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
if ($sColumns != "")
|
|
|
|
$sColumns .= ",";
|
|
|
|
$sColumns .= $sName;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function DropTable($oProc, &$aTables, $sTableName)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]))
|
|
|
|
UnSet($aTables[$sTableName]);
|
2001-01-02 09:22:36 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function DropColumn($oProc, &$aTables, $sTableName, $aNewTableDef, $sColumnName, $bCopyData = true)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]["fd"][$sColumnName]))
|
|
|
|
UnSet($aTables[$sTableName]["fd"][$sColumnName]);
|
2001-01-02 09:22:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
$aNewTables = array();
|
2001-02-11 00:08:52 +01:00
|
|
|
while (list($sTableName, $aTableDef) = each($aTables))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
if ($sTableName == $sOldTableName)
|
|
|
|
$aNewTables[$sNewTableName] = $aTableDef;
|
|
|
|
else
|
|
|
|
$aNewTables[$sTableName] = $aTableDef;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
$aTables = $aNewTables;
|
2001-01-02 09:22:36 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function RenameColumn($oProc, &$aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData = true)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
$aNewTableDef = array();
|
2001-02-11 00:08:52 +01:00
|
|
|
reset($aTables[$sTableName]["fd"]);
|
|
|
|
while (list($sColumnName, $aColumnDef) = each($aTables[$sTableName]["fd"]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
if ($sColumnName == $sOldColumnName)
|
|
|
|
$aNewTableDef[$sNewColumnName] = $aColumnDef;
|
|
|
|
else
|
|
|
|
$aNewTableDef[$sColumnName] = $aColumnDef;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
$aTables[$sTableName]["fd"] = $aNewTableDef;
|
2001-01-02 09:22:36 +01:00
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
reset($aTables[$sTableName]["pk"]);
|
|
|
|
while (list($key, $sColumnName) = each($aTables[$sTableName]["pk"]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
if ($sColumnName == $sOldColumnName)
|
2001-02-11 00:08:52 +01:00
|
|
|
$aTables[$sTableName]["pk"][$key] = $sNewColumnName;
|
2001-01-02 09:22:36 +01:00
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
reset($aTables[$sTableName]["uc"]);
|
|
|
|
while (list($key, $sColumnName) = each($aTables[$sTableName]["uc"]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
|
|
|
if ($sColumnName == $sOldColumnName)
|
2001-02-11 00:08:52 +01:00
|
|
|
$aTables[$sTableName]["uc"][$key] = $sNewColumnName;
|
2001-01-02 09:22:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function AlterColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef, $bCopyData = true)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]["fd"][$sColumnName]))
|
|
|
|
$aTables[$sTableName]["fd"][$sColumnName] = $aColumnDef;
|
2001-02-11 02:30:19 +01:00
|
|
|
|
2001-01-02 09:22:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function AddColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (IsSet($aTables[$sTableName]))
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (!IsSet($aTables[$sTableName]["fd"][$sColumnName]))
|
|
|
|
$aTables[$sTableName]["fd"][$sColumnName] = $aColumnDef;
|
2001-01-02 09:22:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-02-11 00:08:52 +01:00
|
|
|
function CreateTable($oProc, &$aTables, $sTableName, $aTableDef)
|
2001-01-02 09:22:36 +01:00
|
|
|
{
|
2001-02-11 00:08:52 +01:00
|
|
|
if (!IsSet($aTables[$sTableName]))
|
|
|
|
$aTables[$sTableName] = $aTableDef;
|
2001-01-02 09:22:36 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|