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`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
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>
<field name="username" type="C" size="50">
<NOTNULL />
</field>
<field name="password" type="C" size="50">
<NOTNULL />
</field>
<field name="disabled" type="I1">
<NOTNULL />
<UNSIGNED />
<DEFAULT value="0" />
</field>
<index name="i_username">
<col>username</col>
<UNIQUE />
</index>
<index name="i_check_login">
<col>username</col>
<col>password</col>
</index>
</table>
</schema>
|
|
