RE: [PHP] abstraction for databases
| From: | Manuel Lemos | Date: | Sat, 18 Nov 2000 03:41:05 +0000 |
| Subject: | RE: [PHP] abstraction for databases | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26016@lists.php.net to get a copy of this message | ||
Hello Boget,,
On 13-Nov-00 14:14:26, you wrote:
>> If you are looking for one that provides full database independence, ie,
>> you don't need to change your code to switch between databases, you
>> may want to try Metabase:
>> http://phpclasses.UpperDesign.com/browse.html/package/20
>Also, doesn't PHPLIB offer a generic database interface class?
Yes, but it doesn't provide database independence. It's pretty much like
Perl DBI which is the inspiration or several other PHP database interface
packages like PEAR-DB.
For instance, if you want to handle fields with dates, unlike Metabase,
those other packages do not guarantee that the date values always go
formatted in the same standard: ISO 8601 (YYYY-MM-DD). With Metabase you
can definitely write database independent applications.
Another interesting aspect about Metabase is that you can not only access
databases with portable code, but you can (if you want) also install your
database schemas with a database independent specification. You just need to
specify a database independent schema in a custom XML format like the
example below and Metabase classes can create your tables, fields, indexes
and sequences without further worries.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<name>test</name>
<create><variable>create</variable></create>
<table>
<name>users</name>
<declaration>
<field> <name>user_id</name> <type>integer</type>
<default>0</default> <notnull>1</notnull> </field>
<field> <name>user_name</name> <type>text</type>
</field>
<field> <name>user_password</name> <type>text</type>
</field>
<field> <name>reminder</name> <type>text</type>
</field>
<field> <name>name</name> <type>text</type>
</field>
<field> <name>email</name> <type>text</type>
</field>
<index>
<name>users_id_index</name>
<unique>1</unique>
<field> <name>user_id</name> </field>
</index>
</declaration>
</table>
<sequence>
<name>user_id</name>
<start>1</start>
<on> <table>users</table> <field>user_id</field> </on>
</sequence>
<table>
<name>groups</name>
<declaration>
<field> <name>name</name> <type>text</type> </field>
<field> <name>owner_id</name> <type>text</type> </field>
<field> <name>description</name> <type>text</type> </field>
</declaration>
</table>
<table>
<name>group_users</name>
<declaration>
<field> <name>group_id</name> <type>text</type> </field>
<field> <name>user_id</name> <type>text</type> </field>
</declaration>
</table>
</database>
Regards,
Manuel Lemos
Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org
--
E-mail: mlemos@acm.org
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--