Recommend this page to a friend! | Stumble It! | Bookmark in del.icio.us |
All requests | > | What is the best PHP database schema abstraction class? | > | Request new recommendation | > | Featured requests | > | No recommendations | ||
by Till Wehowski - 6 months ago (2015-08-07) database schema abstraction
+3 | I wish to be able to change the applications database schema at a later point easily. So I need to version the tables structures (table names, field names, keys, etc.). And convert DBs between versions. Any sugestions for existing solutions? I do NOT need a class to execute queries. |
+2 | by Samuel Adeshina 775 - 6 months ago (2015-08-07) Comment This class does exactly what you need. check here: http://www.phpclasses.org/metabase for more info |
1. by Manuel Lemos Reply
- 6 months ago (2015-08-07)Well the Metabase package was created with to be a database abstraction layer that supports also schema management.
You can define the database schema of tables, fields, keys, indexes, etc.. in a XML format file.
Then you tell the schema manager to install that schema.
If you want to update the schema, just change the XML schema file and tell the schema manager to update the database performing the necessary changes.
This way you add your application schema file to your project repository, so you can have it versioned too like any other file in the project.
I have been using things for many years and it enabled great productivity and low risk of screwing up your database performing part of the changes when you request changes not supported by the underlying database.
As for a class that does not execute queries, this is tricky. The problem is that Metabase abstracts the table creation and alteration processes. So the resulting SQL queries will be different depending on the database.
I don't know why you do not want to execute the schema changes, but want can be done is to improve Metabase to log queries instead of executing them.
2. by Till Wehowski - 6 months ago (2015-08-07) in reply to comment 1 by Manuel Lemos Reply
Well, it maybe CAN execute queries, but I just use PDO and other classes for this task. As for you said required queries are driver dependent I will try this class, thank you! It looks like it provides exactly what I need.
3. by Manuel Lemos Reply
- 6 months ago (2015-08-07) in reply to comment 2 by Till WehowskiYes, PDO did not exist when this package was created. Still PDO does not provide all the portability you need.
It would be possible to add a PDO driver to this package but then it would require also sub-drivers for each other database.
This was done a long time ago with ODBC because it was the only was to access Microsoft Access databases but it is a lot more work.
Recommend package | |
|