/dd/ -> 0_0032_inc.php
1  <?php
2  
3  // 0_0032_inc.php - See code
4  // 0_0032_inc.php - author: Nico Stuurman
5  
6    /***************************************************************************
7    * Copyright (c) 2002 by Nico Stuurman                                      *
8    * ------------------------------------------------------------------------ *
9    * This code is part of phplabware (http://phplabware.sf.net)               *
10    *                                                                          *
11    *                                                                          *
12    *  This program is free software; you can redistribute it and/or modify it *
13    *  under the terms of the GNU General Public License as published by the   *
14    *  Free Software Foundation; either version 2 of the License, or (at your  *
15    *  option) any later version.                                              *
16    \**************************************************************************/ 
17  
18  // get the real tablenames into a column
19  $db->Execute("ALTER TABLE tableoftables ADD COLUMN table_desc_name text");
20  $db->Execute("ALTER TABLE tableoftables ADD COLUMN label text");
21  $r=$db->Execute("SELECT id,tablename,real_tablename FROM tableoftables");
22  while (!$r->EOF) {
23     $real_tablename=$r->fields["real_tablename"];
24     $tablename=$r->fields["tablename"];
25     $tableid=$r->fields["id"];
26     $db->Execute("UPDATE tableoftables SET label='$tablename' WHERE id='$tableid'");
27     if ($tableid>10000) {
28        $table_desc_name=$real_tablename."_desc";
29        $db->Execute("UPDATE tableoftables SET table_desc_name='$table_desc_name' WHERE id='$tableid'");
30        $db->Execute("ALTER TABLE $table_desc_name ADD COLUMN columnname text");
31        $db->Execute("ALTER TABLE $table_desc_name ADD COLUMN associated_local_key int");
32        $db->Execute("ALTER TABLE $table_desc_name ADD COLUMN thumb_x_size int");
33        $db->Execute("ALTER TABLE $table_desc_name ADD COLUMN thumb_y_size int");
34        $rd=$db->Execute("SELECT id,label FROM $table_desc_name");
35        while (!$rd->EOF) {
36           $db->Execute("UPDATE $table_desc_name SET columnname='".$rd->fields["label"]."' WHERE id='".$rd->fields["id"]."'");
37           $rd->MoveNExt();
38        }
39     }
40     $r->MoveNext();
41  }
42  
43  ?>