/dd/ -> 0_0034_inc.php
1  <?php
2  
3  // 0_0034_inc.php - See code
4  // 0_0034_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  $db->Execute("ALTER TABLE files ADD COLUMN ftablecolumnid int");
19  $r=$db->Execute("SELECT id,tablesfk,ftableid FROM files");
20  while (!$r->EOF) {
21     $rb=$db->Execute("SELECT id,real_tablename,table_desc_name FROM tableoftables WHERE id='".$r->fields["tablesfk"]."'");
22     if ($rb->fields["id"]> 9999) {
23        $rc=$db->Execute("SELECT id FROM ".$rb->fields["table_desc_name"]." WHERE datatype='file'");
24        $rd=$db->Execute("UPDATE files SET ftablecolumnid='".$rc->fields["id"]."' WHERE id='".$r->fields["id"]."'"); 
25     }
26     // for the old tables, simply set columnid to 1.  This might be important
27     // if table descriptions for the old tables will ever be made
28     else
29        $rd=$db->Execute("UPDATE files SET ftablecolumnid='1' WHERE id='".$r->fields["id"]."'");
30     $r->MoveNext();
31  }
32  
33  ?>