Hello,
A new Metabase release is imminent. All new features were implemented,
tested and documented. I am just finishing to update the tutorials and
tomorrow I expect to make a release.
The current development of Metabase features is mostly motivated to
address needs of Metastorage. Since it takes a lot of time to enhance
all the available drivers to implement the new features, for now only
MySQL, PostgreSQL and Oracle drivers were updated.
In case you are not yet aware, I have put up a survey to figure which
other drivers would be worth investing time to update, giving priority
to databases that users that really intend to use Metastorage want to
use. So, if you want to use Metastorage, please go to this survey page
and indicate which database or databases you want to use Metastorage.
After a long time without significant enhancements to Metabase, I am
finally adding support to database schema features like auto-increment
fields and primary keys. Future versions of Metastorage will generate
code that takes advantage of these features.
http://groups.yahoo.com/group/metal-dev/surveys?id=12118553
If you don't know what Metastorage is, it is a code generator tool that
generate classes of objects that perform object-relational mapping based
on a model definition in a XML format.
This is basically meant to provide dramatic improvement in the quality
of PHP database application development, reducing drastically the
development time, especially of medium or large scale applications.
http://www.meta-language.net/metastorage.html
As for this release of Metabase it provides:
- Support for auto-increment key fields in a database independent way.
It works very well even on databases like Oracle that do not support
auto-increment fields natively.
There are new API functions to support auto-increment fields:
GetNextKey, GetInsertedKey, and SetQueryKey which is a very innovating
feature that lets you bind a value of a prepared query to an
auto-increment table field.
Using just these functions Metabase figures automatically whether native
auto-increment fields or sequences will be used. There is no need to
verify that at runtime and the code will always be database independent.
- Support for primary keys. Primary keys are implicit with tables using
auto-incremented key fields but Metabase also supports compound keys.
- Migration to alter tables and start using auto-increment fields and
primary keys works flawlessly. I have implemented this in the PHP
Classes site that has tens of tables that were migrated with a simple
change in a XML database schema definition.
If before you had>
<table>
<name>sometable</name>
<declaration>
<field> <name>id</name> <type>integer</type> <notnull>1</notnull>
<default>0</default> </field>
<field> <name>someotherfield</name> <type>text</type> </field>
<index>
<name>sometable_id_index</name>
<field> <name>id</name> </field>
<unique>1</unique>
</index>
</declaration>
</table>
<sequence>
<name>sometable_id</name>
<start>1</start>
<on> <table>file_accesses_queue</table> <field>id</field> </on>
</sequence>
Now you just need this:
<table>
<name>sometable</name>
<declaration>
<field> <name>id</name> <autoincrement>1</autoincrement> </field>
<field> <name>someotherfield</name> <type>text</type> </field>
</declaration>
</table>
Migrating from one kind of schema to the other just takes this change.
Metabase will take care of the field changes and the implicit primary
key association.
As for applications code you just need to change something like this:
$db->GetNextSequenceValue("sometable_id", $id);
$db->Query("INSERT INTO sometable (id, someotherfield) VALUES(".$id,",
'some other value')";
to:
$db->GetNextKey("sometable", $key);
$db->Query("INSERT INTO sometable (id, someotherfield) VALUES(".$key,",
'some other value')";
$db->GetInsertedKey("sometable", $id);
- There are new database manager API functions named
CreateDetailedTable and DropDetailedTable. These are used by the schema
manager class to create and drop tables with auto-increment fields and
primary keys.
- The schema manager now performs a safety check when installing or
altering databases with new tables. If it is not possible to create a
table because the current driver does not support some features, nothing
is changed in the database and the schema manager will return an
explanatory error message.
- Schema reverse engineering of database tables with auto-increment
fields or primary keys is now implemented for now for MySQL only.
- The driver test suite has now a new tests named autoincrement and
preparedautoincrement that try to insert a few records in a new table
with an autoincrement field and verifies if it worked correctly either
using direct queries or prepared queries.
For now this new version is available in CVS. You may find instructions
on how to obtain access to the CVS server or a download daily snapshots
from here:
http://www.meta-language.net/download.html
Please test these improvements and let me know if you would like to seem
them also implemented in databases that are not yet supported.
The updated version of the documentation is available here. The tutorial
will be updated soon.
http://www.meta-language.net/metabase.html
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html