check_table helper moved.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 22 Nov 2010 21:10:55 +0000 (21:10 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 22 Nov 2010 21:10:55 +0000 (21:10 +0000)
admin/db/maintenance_db.inc
admin/inst_upgrade.php

index 9e0793f17c014173ac08dccb9fda2064329475c1..e453c97bc537effdbddc3f02f031bbb4193eec9c 100644 (file)
@@ -802,4 +802,39 @@ function create_comp_dirs($comp_path, $comp_subdirs)
                        @fclose($f);
            }
 }
+
+//
+//     Checks $field existence in $table with given field $properties
+//     $table - table name without prefix
+//  $field -  optional field name
+//  $properties - optional properties of field defined by MySQL:
+//             'Type', 'Null', 'Key', 'Default', 'Extra'
+//
+function check_table($pref, $table, $field=null, $properties=null)
+{
+       $tables = @db_query("SHOW TABLES LIKE '".$pref.$table."'");
+       if (!db_num_rows($tables))
+               return 1;               // no such table or error
+
+       $fields = @db_query("SHOW COLUMNS FROM ".$pref.$table);
+       if (!isset($field)) 
+               return 0;               // table exists
+
+       while( $row = db_fetch_assoc($fields)) 
+       {
+               if ($row['Field'] == $field) 
+               {
+                       if (!isset($properties)) 
+                               return 0;
+                       foreach($properties as $property => $value) 
+                       {
+                               if ($row[$property] != $value) 
+                                       return 3;       // failed type/length check
+                       }
+                       return 0; // property check ok.
+               }
+       }
+       return 2; // field not found
+}
+
 ?>
\ No newline at end of file
index bd9e1b4ba4f6a610b639e52944ed548177a06e91..399cf8185667945426183cd0b01b8b8e3482399a 100644 (file)
@@ -20,39 +20,6 @@ include_once($path_to_root . "/admin/db/company_db.inc");
 include_once($path_to_root . "/admin/db/maintenance_db.inc");
 include_once($path_to_root . "/includes/ui.inc");
 
-//
-//     Checks $field existence in $table with given field $properties
-//     $table - table name without prefix
-//  $field -  optional field name
-//  $properties - optional properties of field defined by MySQL:
-//             'Type', 'Null', 'Key', 'Default', 'Extra'
-//
-function check_table($pref, $table, $field=null, $properties=null)
-{
-       $tables = @db_query("SHOW TABLES LIKE '".$pref.$table."'");
-       if (!db_num_rows($tables))
-               return 1;               // no such table or error
-
-       $fields = @db_query("SHOW COLUMNS FROM ".$pref.$table);
-       if (!isset($field)) 
-               return 0;               // table exists
-
-       while( $row = db_fetch_assoc($fields)) 
-       {
-               if ($row['Field'] == $field) 
-               {
-                       if (!isset($properties)) 
-                               return 0;
-                       foreach($properties as $property => $value) 
-                       {
-                               if ($row[$property] != $value) 
-                                       return 3;       // failed type/length check
-                       }
-                       return 0; // property check ok.
-               }
-       }
-       return 2; // field not found
-}
 //
 //     Creates table of installer objects sorted by version.
 //