MySQL "Create table" to ADODB XML Schema (AXMLS) converter

Публикувано / posted 2008-09-23 в категория / in category: Tangra Framework for PHP, Web development

During the development of Tangra CMS installer I found that it is really annoying when you have to convert multiple tables from MySQL CREATE TABLE to Adodb's XML schema format by hand. I had to convert more than 20 tables and I decided to write simple converter that will automate this task. The result is MySQL "Create table" to ADODB XML Schema (AXMLS) converter

Generally speaking it takes something like:

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  `disabled` tinyint(3) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `i_username` (`username`),
  KEY `i_check_login` (`username`,`password`)

as an input and as output generates:

<?xml version="1.0"?>
<schema version="0.3">
    <table name="users">
	    <opt platform="mysql">ENGINE=InnoDB DEFAULT CHARSET=utf8</opt>

            <field name="id" type="I4">
                <NOTNULL />
                <KEY />
                <UNSIGNED />

            <field name="username" type="C" size="50">
                <NOTNULL />

            <field name="password" type="C" size="50">

                <NOTNULL />

            <field name="disabled" type="I1">
                <NOTNULL />
                <UNSIGNED />

                <DEFAULT value="0" />

            <index name="i_username">

                <UNIQUE />

            <index name="i_check_login">



2 Responses to “MySQL "Create table" to ADODB XML Schema (AXMLS) converter”

  1. piotrd says:

    I like the tool! Would it be possible for you to share the source code? I would like to enhance it a bit.

  2. Огнян says:

    Hi, here you can find the class:
    Please note that this is kind of old aproach. Probably will be much better to read the table definitions directly from the MySql information_schema.

Leave a Reply

Внимание: Моля, въведете само ПЪРВИТЕ ТРИ цифри от картинката
Important: Please enter just the first three digits from the image