History of Schema tutorial

Differences from version 2 to 3



@@ -1,2 +1,56 @@

 packagename/admin/schema_inc.php contain adodb syntax for creating the packages database, this doc describes the syntax.
 [http://phplens.com/lens/adodb/docs-datadict.htm|adodbsyntax]
+
+^If anyone is interested, there is experimental code in /install/migrate_database.php which will try and convert a connect database to AdoDB DataDict syntax - the same used in schema_inc.php.
+
+Not sure if the people at AdoDB would find it useful - but anyone converting a database schema by hand will definitely find it valuable.
+
+Stephan aka wolff_borg^
+
+{code src=php} // iterate through source tables
+ foreach($tables_src as $table) {
+...
+ $schema = $gDb_src->MetaColumns( $table, false, true );
+ $t = "";
+ $first = true;
+ foreach(array_keys($schema) as $col) {
+ $t .= (!$first) ? ",\n" : "";
+ $x = $schema[$col];
+ $t .= $x->name . " ";
+ switch($x->type) {
+ case "int":
+ $i = abs(( ( (int)$x->max_length ^ 2) - 1 ));
+ $i = ($i == 5) ? 4 : $i;
+ $i = ($i == 0) ? 1 : $i;
+ $t .= "I" . $i;
+ break;
+
+ case "varchar":
+ case "char":
+ $t .= "C(" . $x->max_length . ")";
+ break;
+
+ case "datetime":
+ $t .= "T";
+ break;
+
+ case "longblob":
+ case "text":
+ $t .= "X";
+ break;
+
+ default:
+ die($x->type);
+ }
+ $default = (!$x->binary) ? $x->has_default : false;
+ $t .= " " . ( ($x->unsigned) ? "UNSIGNED" : "" ) . " "
+ . ( ($x->not_null) ? "NOTNULL" : "" ) . " "
+ . ( ($x->auto_increment) ? "AUTO" : "" ) . " "
+ . ( ($x->primary_key) ? "PRIMARY" : "" ) . " "
+ . ( ($default) ? "DEFAULT ". $x->default_value : "" );
+ $table_schema[$table] = $t;
+ $first = false;
+ }
+ $indices[$table] = $gDb_src->MetaIndexes( $table, false, false );
+ }
+{/code}
Page History
Date/CommentUserIPVersion
18 Nov 2005 (17:28 UTC)
Stephan Borg218.214.1.1133
Current • Source
Filipino Filipiciu86.104.101.642
View • Compare • Difference • Source
Giles Westwood86.128.234.111
View • Compare • Difference • Source