Adding remaining schema.xml files, one per table...still more to come.
[moodle.git] / lib / db / schema.php
1 <?php 
2 echo "<h2>Moodle lib/db ADODB XML Schema</h2>";
3 include_once('tohtml.inc.php'); 
4 include_once('adodb.inc.php'); 
5 include_once('adodb-xmlschema.inc.php'); 
6 $database = "oci8po";
7 $db = ADONewConnection("$database"); 
8 $db->debug = true;
9 $server = "false";
10 $user = "scott";
11 $password = "tiger";
12 $db->Connect(false, $user, $password); 
13 $rs = $db->Execute('select * from dept'); 
14 print "<pre>"; 
15 print_r($rs->GetRows()); 
16 print "</pre>"; 
17 rs2html($rs,'border=2 cellpadding=3',array('Deptno','DName','Loc'));
18 $dict = NewDataDictionary($db);
20 echo "<h3>schemaConfig.xml</h3>";
21 $rs = $db->Execute('drop table config');
22 $rs = $db->Execute('drop sequence SEQ_config');
23 $schema = new adoSchema($db);
24 $sql = $schema->ParseSchema("schemaConfig.xml");
25 $result = $schema->ExecuteSchema( $sql );
26 $sql = "insert into config values (2,'2','2')";
27 $rs = $db->Execute($sql);
28 $sql = "insert into config values (3,'3','3')";
29 $rs = $db->Execute($sql);
30 $rs = $db->Execute('select * from config');
31 rs2html($rs,'border=2 cellpadding=3',array('id','name','value'));
32 echo "<h3>schemaCourse.xml</h3>";
34 $schema = new adoSchema($db);
35 $sql = $schema->ParseSchema("schemaCourse.xml");
36 $rs = $db->Execute('drop table course');
37 $rs = $db->Execute('drop sequence SEQ_course');
38 $result = $schema->ExecuteSchema( $sql );
39 $sql = "insert into course values (2,2,2,'2','2','2','2','2',2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)";
40 $rs = $db->Execute($sql);
41 $sql = "insert into course values (3,3,3,'3','3','3','3','3',3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3)";
42 $rs = $db->Execute($sql);
43 $rs = $db->Execute('select * from course');
44 rs2html($rs,'border=2 cellpadding=3',array('id','category','sortorder','password','fullname','shortname','summary','format','showgrades','modinfo','newsitems','teacher','teachers','student','students','guest','startdate','numsections','showrecent','marker','maxbytes','showreports','visible','timecreated','timemodified'));
46 echo "<h3>schemaCourse_categories.xml</h3>";
47 $rs = $db->Execute('drop table course_categories');
48 $rs = $db->Execute('drop sequence SEQ_course_categories');
49 $schema = new adoSchema($db);
50 $sql = $schema->ParseSchema("schemaCourse_categories.xml");
51 $result = $schema->ExecuteSchema( $sql );
52 $sql = "insert into Course_categories values (2,'2','2',2,2,2,2,2)";
53 $rs = $db->Execute($sql);
54 $sql = "insert into Course_categories values (3,'3','3',3,3,3,3,3)";
55 $rs = $db->Execute($sql);
56 $rs = $db->Execute('select * from Course_categories');
57 rs2html($rs,'border=2 cellpadding=3',array('id','name','description','parent','sortorder','coursecount','visible','timemodified'));
59 echo "<h3>schemaCourse_display.xml</h3>";
60 $rs = $db->Execute('drop table course_display');
61 $rs = $db->Execute('drop sequence SEQ_course_display');
62 $schema = new adoSchema($db);
63 $sql = $schema->ParseSchema("schemaCourse_display.xml");
64 $result = $schema->ExecuteSchema( $sql );
65 $sql = "insert into Course_display values (2,2,2,2)";
66 $rs = $db->Execute($sql);
67 $sql = "insert into Course_display values (3,3,3,3)";
68 $rs = $db->Execute($sql);
69 $rs = $db->Execute('select * from Course_display');
70 rs2html($rs,'border=2 cellpadding=3',array('id','course','userid','display'));
72 echo "<h3>schemaCourse_modules.xml</h3>";
73 $rs = $db->Execute('drop table course_modules');
74 $rs = $db->Execute('drop sequence SEQ_course_modules');
75 $schema = new adoSchema($db);
76 $sql = $schema->ParseSchema("schemaCourse_modules.xml");
77 $result = $schema->ExecuteSchema( $sql );
78 $sql = "insert into Course_modules values (2,2,2,2,2,2,2,2,2,2)";
79 $rs = $db->Execute($sql);
80 $sql = "insert into Course_modules values (3,3,3,3,3,3,3,3,3,3)";
81 $rs = $db->Execute($sql);
82 $rs = $db->Execute('select * from Course_modules');
83 rs2html($rs,'border=2 cellpadding=3',array('id','course','module','instance','section','added','deleted','score','indent','visible'));
85 echo "<h3>schemaCourse_sections.xml</h3>";
86 $rs = $db->Execute('drop table course_sections');
87 $rs = $db->Execute('drop sequence SEQ_course_sections');
88 $schema = new adoSchema($db);
89 $sql = $schema->ParseSchema("schemaCourse_sections.xml");
90 $result = $schema->ExecuteSchema( $sql );
91 $sql = "insert into Course_sections values (2,2,2,2,2,2)";
92 $rs = $db->Execute($sql);
93 $sql = "insert into Course_sections values (3,3,3,3,3,3)";
94 $rs = $db->Execute($sql);
95 $rs = $db->Execute('select * from Course_sections');
96 rs2html($rs,'border=2 cellpadding=3',array('id','course','section','summary','sequence','visible'));
98 echo "<h3>schemaCourse_groups.xml</h3>";
99 $rs = $db->Execute('drop table course_groups');
100 $rs = $db->Execute('drop sequence SEQ_course_groups');
101 $schema = new adoSchema($db);
102 $sql = $schema->ParseSchema("schemaCourse_groups.xml");
103 $result = $schema->ExecuteSchema( $sql );
104 $sql = "insert into Course_groups values (2,2,2,2,2,2,2,2)";
105 $rs = $db->Execute($sql);
106 $sql = "insert into Course_groups values (3,3,3,3,3,3,3,3)";
107 $rs = $db->Execute($sql);
108 $rs = $db->Execute('select * from Course_groups');
109 rs2html($rs,'border=2 cellpadding=3',array('id','courseid','name','description','lang','picture','timecreated','timemodified'));
111 echo "<h3>schemaCourse_groups_members.xml</h3>";
112 $rs = $db->Execute('drop table course_groups_members');
113 $rs = $db->Execute('drop sequence SEQ_course_groups_members');
114 $schema = new adoSchema($db);
115 $sql = $schema->ParseSchema("schemaCourse_groups_members.xml");
116 $result = $schema->ExecuteSchema( $sql );
117 $sql = "insert into Course_groups_members values (2,2,2,2)";
118 $rs = $db->Execute($sql);
119 $sql = "insert into Course_groups_members values (3,3,3,3)";
120 $rs = $db->Execute($sql);
121 $rs = $db->Execute('select * from Course_groups_members');
122 rs2html($rs,'border=2 cellpadding=3',array('id','courseid','name','description','lang','picture','timecreated','timemodified'));
124 echo "<h3>schemaLog.xml</h3>";
125 $rs = $db->Execute('drop table log');
126 $rs = $db->Execute('drop sequence SEQ_log');
127 $schema = new adoSchema($db);
128 $sql = $schema->ParseSchema("schemaLog.xml");
129 $result = $schema->ExecuteSchema( $sql );
130 $sql = "insert into log values (2,2,2,2,2,2,2,2,2)";
131 $rs = $db->Execute($sql);
132 $sql = "insert into log values (3,3,3,3,3,3,3,3,3)";
133 $rs = $db->Execute($sql);
134 $rs = $db->Execute('select * from log');
135 rs2html($rs,'border=2 cellpadding=3',array('id','time','userid','ip','course','module','action','url','info'));
137 echo "<h3>schemaLog_display.xml</h3>";
138 $rs = $db->Execute('drop table log_display');
139 $rs = $db->Execute('drop sequence SEQ_log_display');
140 $schema = new adoSchema($db);
141 $sql = $schema->ParseSchema("schemalog_display.xml");
142 $result = $schema->ExecuteSchema( $sql );
143 $sql = "insert into log_display values (2,2,2,2)";
144 $rs = $db->Execute($sql);
145 $sql = "insert into log_display values (3,3,3,3)";
146 $rs = $db->Execute($sql);
147 $rs = $db->Execute('select * from log_display');
148 rs2html($rs,'border=2 cellpadding=3',array('id','time','userid','ip','course','module','action','url','info'));
150 echo "<h3>schemaModules.xml</h3>";
151 $rs = $db->Execute('drop table modules');
152 $rs = $db->Execute('drop sequence SEQ_modules');
153 $schema = new adoSchema($db);
154 $sql = $schema->ParseSchema("schemamodules.xml");
155 $result = $schema->ExecuteSchema( $sql );
156 $sql = "insert into modules values (2,2,2,2,2,2,2)";
157 $rs = $db->Execute($sql);
158 $sql = "insert into modules values (3,3,3,3,3,3,3)";
159 $rs = $db->Execute($sql);
160 $rs = $db->Execute('select * from modules');
161 rs2html($rs,'border=2 cellpadding=3',array('id','name','version','cron','lastcron','search','visible'));
163 echo "<h3>schemaScale.xml</h3>";
164 $rs = $db->Execute('drop table scale');
165 $rs = $db->Execute('drop sequence SEQ_scale');
166 $schema = new adoSchema($db);
167 $sql = $schema->ParseSchema("schemaScale.xml");
168 $result = $schema->ExecuteSchema( $sql );
169 $sql = "insert into scale values (2,2,2,2,2,2,2)";
170 $rs = $db->Execute($sql);
171 $sql = "insert into scale values (3,3,3,3,3,3,3)";
172 $rs = $db->Execute($sql);
173 $rs = $db->Execute('select * from scale');
174 rs2html($rs,'border=2 cellpadding=3',array('id','courseid','userid','name','scale','description','timemodified'));
176 echo "<h3>schemaUser.xml</h3>";
177 $rs = $db->Execute('drop table m_user');
178 $rs = $db->Execute('drop sequence SEQ_m_user');
179 $schema = new adoSchema($db);
180 $sql = $schema->ParseSchema("schemaUser.xml");
181 $result = $schema->ExecuteSchema( $sql );
182 $sql = "insert into m_user values (2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)";
184 $rs = $db->Execute($sql);
185 $sql = "insert into m_user values (3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3)";
186 $rs = $db->Execute($sql);
187 $rs = $db->Execute('select * from m_user');
188 rs2html($rs,'border=2 cellpadding=3',array('id','confirmed','deleted','m_username','password','idnumber','firstname','lastname','email','icq','phone1','phone2','institution','department','address','city','country','lang','timezone','firstaccess','lastaccess','lastlogin','currentlogin','lastIP','secret','picture','url','description','mailformat','maildisplay','htmleditor','autosubscribe','timemodified'));
191 echo "<h3>schemaUser_admins.xml</h3>";
192 $rs = $db->Execute('drop table user_admins');
193 $rs = $db->Execute('drop sequence SEQ_user_admins');
194 $schema = new adoSchema($db);
195 $sql = $schema->ParseSchema("schemaUser_admins.xml");
196 $result = $schema->ExecuteSchema( $sql );
197 $sql = "insert into user_admins values (2,2)";
199 $rs = $db->Execute($sql);
200 $sql = "insert into user_admins values (3,3)";
201 $rs = $db->Execute($sql);
202 $rs = $db->Execute('select * from user_admins');
203 rs2html($rs,'border=2 cellpadding=3',array('id','userid'));
205 ?>