Reverse Engineer MySQL db Table -> db.xml

Permalink 2 users found helpful
This is getting annoying - I've got these huge tables that already exist and it's getting a little old having to manually create the db.xml file... I tried the one here:

http://www.tangraframework.net/mysql_axmls.php...

But it seems to generate an error for anything but a really simple table.

Any ideas? suggestions? I'm really not in the mood to manually create the db.xml file if I can help it :(

jtrelfa
 
jtrelfa replied on at Permalink Best Answer Reply
jtrelfa
Found the answer (sorry - was getting frustrated)

1. Download ADODB5http://sourceforge.net/projects/adodb/files/adodb-php5-only/adodb-5...
2. unzip it into a folder on your server
3. create a page for performing the extract (I called mine dbextract.php):
<?php
require( "adodb5/adodb.inc.php");
//remove the '03' from the file name to use axmls version 2
require( "adodb5/adodb-xmlschema03.inc.php" );
$platform = 'mysql';
$dbHost = 'localhost';
$dbName = 'db name';
$dbUser = 'db user';
$dbPassword = 'password';
$db = ADONewConnection( $platform );
$db->Connect( $dbHost, $dbUser, $dbPassword, $dbName );
$schema = new adoSchema( $db );
//the first arg is so you don't get the data, the second arg is what is used to indent the xml
echo $schema->ExtractSchema(FALSE,"\t");

4. visit the page you created (e.g.http://localhost/dbextract.php)...
5. Save the file
stephendmalloy replied on at Permalink Reply
stephendmalloy
This works well - you're the man. I even whipped up an interface and it works quite well...thanks! When I have time some day I'll probably create an add-on for this