/dd/ -> 0_1002_inc.php
1 <?php
2
3 // Adds column 'indexed' to table files
4 // Adds associated tables for indexing to every column of type 'file'
5 $db->Execute("ALTER TABLE files ADD COLUMN indexed integer");
6 $db->Execute("CREATE INDEX files_indexed ON files (indexed)");
7
8 $rdesc=$db->Execute("SELECT real_tablename,table_desc_name FROM tableoftables");
9 while (!($rdesc->EOF)) {
10 if($rdesc->fields[table_desc_name]) {
11 $rfile=$db->Execute("SELECT id FROM ".$rdesc->fields[table_desc_name]." WHERE datatype='file'");
12 while (!($rfile->EOF)) {
13 if ($rfile->fields[id]) {
14 $tablestr=$rdesc->fields[real_tablename]."_wi_".$rfile->fields[id];
15 $rs=$db->Execute("CREATE TABLE $tablestr (wordid int, fileid int,pagenr int, recordid int,UNIQUE (wordid,fileid,pagenr,recordid))");
16 // Create indices
17 $db->Execute("CREATE INDEX $tablestr"."_wi ON $tablestr(wordid)");
18 $db->Execute("CREATE INDEX $tablestr"."_fi ON $tablestr(fileid)");
19 $db->Execute("CREATE INDEX $tablestr"."_ri ON $tablestr(recordid)");
20 // And add entry in description table
21 $db->Execute("UPDATE ".$rdesc->fields[table_desc_name]." SET associated_table='$tablestr' WHERE id=".$rfile->fields[id]);
22 }
23 $rfile->MoveNext();
24 }
25 }
26 $rdesc->MoveNext();
27 }
28
29 ?>