00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 error_reporting(E_ALL);
00014 include_once('../adodb.inc.php');
00015
00016 foreach(array('sapdb','sybase','mysql','access','oci8po','postgres','odbc_mssql','odbc','db2','firebird','informix') as $dbType) {
00017 echo "<h3>$dbType</h3><p>";
00018 $db = NewADOConnection($dbType);
00019 $dict = NewDataDictionary($db);
00020
00021 if (!$dict) continue;
00022 $dict->debug = 1;
00023
00024 $opts = array('REPLACE','mysql' => 'ENGINE=INNODB', 'oci8' => 'TABLESPACE USERS');
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 $flds = "
00049 ID I AUTO KEY,
00050 FIRSTNAME VARCHAR(30) DEFAULT 'Joan',
00051 LASTNAME VARCHAR(28) DEFAULT 'Chen' key,
00052 averylonglongfieldname X(1024) DEFAULT 'test',
00053 price N(7.2) DEFAULT '0.00',
00054 MYDATE D DEFDATE,
00055 BIGFELLOW X NOTNULL,
00056 TS T DEFTIMESTAMP";
00057
00058
00059 $sqla = $dict->CreateDatabase('KUTU',array('postgres'=>"LOCATION='/u01/postdata'"));
00060 $dict->SetSchema('KUTU');
00061
00062 $sqli = ($dict->CreateTableSQL('testtable',$flds, $opts));
00063 $sqla = array_merge($sqla,$sqli);
00064
00065 $sqli = $dict->CreateIndexSQL('idx','testtable','firstname,lastname',array('BITMAP','FULLTEXT','CLUSTERED','HASH'));
00066 $sqla = array_merge($sqla,$sqli);
00067 $sqli = $dict->CreateIndexSQL('idx2','testtable','price,lastname');
00068 $sqla = array_merge($sqla,$sqli);
00069
00070 $addflds = array(array('height', 'F'),array('weight','F'));
00071 $sqli = $dict->AddColumnSQL('testtable',$addflds);
00072 $sqla = array_merge($sqla,$sqli);
00073 $addflds = array(array('height', 'F','NOTNULL'),array('weight','F','NOTNULL'));
00074 $sqli = $dict->AlterColumnSQL('testtable',$addflds);
00075 $sqla = array_merge($sqla,$sqli);
00076
00077
00078 printsqla($dbType,$sqla);
00079
00080 if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php'))
00081 if ($dbType == 'mysqlt') {
00082 $db->Connect('localhost', "root", "", "test");
00083 $dict->SetSchema('');
00084 $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
00085 if ($sqla2) printsqla($dbType,$sqla2);
00086 }
00087 if ($dbType == 'postgres') {
00088 if (@$db->Connect('localhost', "tester", "test", "test"));
00089 $dict->SetSchema('');
00090 $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
00091 if ($sqla2) printsqla($dbType,$sqla2);
00092 }
00093
00094 if ($dbType == 'odbc_mssql') {
00095 $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
00096 if (@$db->Connect($dsn, "sa", "natsoft", "test"));
00097 $dict->SetSchema('');
00098 $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
00099 if ($sqla2) printsqla($dbType,$sqla2);
00100 }
00101
00102
00103
00104 adodb_pr($dict->databaseType);
00105 printsqla($dbType, $dict->DropColumnSQL('table',array('my col','`col2_with_Quotes`','A_col3','col3(10)')));
00106 printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)'));
00107
00108 }
00109
00110 function printsqla($dbType,$sqla)
00111 {
00112 print "<pre>";
00113
00114 foreach($sqla as $s) {
00115 $s = htmlspecialchars($s);
00116 print "$s;\n";
00117 if ($dbType == 'oci8') print "/\n";
00118 }
00119 print "</pre><hr />";
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 echo "<h1>Test XML Schema</h1>";
00243 $ff = file('xmlschema.xml');
00244 echo "<pre>";
00245 foreach($ff as $xml) echo htmlspecialchars($xml);
00246 echo "</pre>";
00247 include_once('test-xmlschema.php');
00248 ?>