source: trunk/phpgwapi/inc/class.schema_proc_array.inc.php @ 2

Revision 2, 4.7 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * wGroupWare - Setup                                                       *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  * This file written by Michael Dean<mdean@users.sourceforge.net>           *
7  *  and Miles Lott<milosch@groupwhere.org>                                  *
8  * --------------------------------------------                             *
9  *  This program is free software; you can redistribute it and/or modify it *
10  *  under the terms of the GNU General Public License as published by the   *
11  *  Free Software Foundation; either version 2 of the License, or (at your  *
12  *  option) any later version.                                              *
13  \**************************************************************************/
14
15
16        class schema_proc_array
17        {
18                var $m_sStatementTerminator;
19
20                function schema_proc_array()
21                {
22                        $this->m_sStatementTerminator = ';';
23                }
24
25                /* Return a type suitable for DDL abstracted array */
26                function TranslateType($sType, $iPrecision = 0, $iScale = 0)
27                {
28                        $sTranslated = $sType;
29                        return $sTranslated;
30                }
31
32                function TranslateDefault($sDefault)
33                {
34                        return $sDefault;
35                }
36
37                function GetPKSQL($sFields)
38                {
39                        return '';
40                }
41
42                function GetUCSQL($sFields)
43                {
44                        return '';
45                }
46
47                function _GetColumns($oProc, &$aTables, $sTableName, &$sColumns, $sDropColumn='')
48                {
49                        $sColumns = '';
50                        while(list($sName, $aJunk) = each($aTables[$sTableName]['fd']))
51                        {
52                                if($sColumns != '')
53                                {
54                                        $sColumns .= ',';
55                                }
56                                $sColumns .= $sName;
57                        }
58
59                        return True;
60                }
61
62                function DropTable($oProc, &$aTables, $sTableName)
63                {
64                        if(isset($aTables[$sTableName]))
65                        {
66                                unset($aTables[$sTableName]);
67                        }
68                       
69                        return True;
70                }
71
72                function DropColumn($oProc, &$aTables, $sTableName, $aNewTableDef, $sColumnName, $bCopyData=True)
73                {
74                        if(isset($aTables[$sTableName]))
75                        {
76                                if(isset($aTables[$sTableName]['fd'][$sColumnName]))
77                                {
78                                        unset($aTables[$sTableName]['fd'][$sColumnName]);
79                                }
80                        }
81
82                        return True;
83                }
84
85                function RenameTable($oProc, &$aTables, $sOldTableName, $sNewTableName)
86                {
87                        $aNewTables = array();
88                        while(list($sTableName, $aTableDef) = each($aTables))
89                        {
90                                if($sTableName == $sOldTableName)
91                                {
92                                        $aNewTables[$sNewTableName] = $aTableDef;
93                                }
94                                else
95                                {
96                                        $aNewTables[$sTableName] = $aTableDef;
97                                }
98                        }
99
100                        $aTables = $aNewTables;
101
102                        return True;
103                }
104
105                function RenameColumn($oProc, &$aTables, $sTableName, $sOldColumnName, $sNewColumnName, $bCopyData=True)
106                {
107                        if (isset($aTables[$sTableName]))
108                        {
109                                $aNewTableDef = array();
110                                reset($aTables[$sTableName]['fd']);
111                                while(list($sColumnName, $aColumnDef) = each($aTables[$sTableName]['fd']))
112                                {
113                                        if($sColumnName == $sOldColumnName)
114                                        {
115                                                $aNewTableDef[$sNewColumnName] = $aColumnDef;
116                                        }
117                                        else
118                                        {
119                                                $aNewTableDef[$sColumnName] = $aColumnDef;
120                                        }
121                                }
122
123                                $aTables[$sTableName]['fd'] = $aNewTableDef;
124
125                                reset($aTables[$sTableName]['pk']);
126                                while(list($key, $sColumnName) = each($aTables[$sTableName]['pk']))
127                                {
128                                        if($sColumnName == $sOldColumnName)
129                                        {
130                                                $aTables[$sTableName]['pk'][$key] = $sNewColumnName;
131                                        }
132                                }
133
134                                reset($aTables[$sTableName]['ix']);
135                                while(list($key,$sColumnName) = each($aTables[$sTableName]['ix']))
136                                {
137                                        if ($sColumnName == $sOldColumnName)
138                                        {
139                                                $aTables[$sTableName]['ix'][$key] = $sNewColumnName;
140                                        }
141                                }
142
143                                reset($aTables[$sTableName]['uc']);
144                                while(list($key, $sColumnName) = each($aTables[$sTableName]['uc']))
145                                {
146                                        if($sColumnName == $sOldColumnName)
147                                        {
148                                                $aTables[$sTableName]['uc'][$key] = $sNewColumnName;
149                                        }
150                                }
151                        }
152
153                        return True;
154                }
155
156                function AlterColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef, $bCopyData=True)
157                {
158                        if(isset($aTables[$sTableName]))
159                        {
160                                if(isset($aTables[$sTableName]['fd'][$sColumnName]))
161                                {
162                                        $aTables[$sTableName]['fd'][$sColumnName] = $aColumnDef;
163                                }
164                        }
165
166                        return True;
167                }
168
169                function AddColumn($oProc, &$aTables, $sTableName, $sColumnName, &$aColumnDef)
170                {
171                        if(isset($aTables[$sTableName]))
172                        {
173                                if(!isset($aTables[$sTableName]['fd'][$sColumnName]))
174                                {
175                                        $aTables[$sTableName]['fd'][$sColumnName] = $aColumnDef;
176                                }
177                        }
178
179                        return True;
180                }
181
182                function CreateTable($oProc, &$aTables, $sTableName, $aTableDef)
183                {
184                        if(!isset($aTables[$sTableName]))
185                        {
186                                $aTables[$sTableName] = $aTableDef;
187                        }
188
189                        return True;
190                }
191
192                function RefreshTable($oProc, &$aTables, $sTableName, $aTableDef)
193                {
194                        $aTables[$sTableName] = $aTableDef;
195
196                        return True;
197                }
198        }
199?>
Note: See TracBrowser for help on using the repository browser.