For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > March 2006 > Re: [PEAR] DB & MDB2 Portability









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] DB & MDB2 Portability
Justin Patrin

2006-03-02, 3:56 am

On 3/1/06, Paul Scott <pscott@uwc.ac.za> wrote:
> I have recently started porting one of our (very) large applications
> from PHP4 + DB to PHP5 + MDB2.
>
> My question is as follows:
>
> In the PHP4 version, we used MySQL as the primary RDBMS, but in the PHP5
> version would like to give the user the option to use Postgres, Oracle
> and MSSQL as well. As far as I can see, things should all be OK with the
> different backends, but for one question. Can MDB2 abstract the column
> types and names properly?


Yes.

> I see that there is support for datetime
> columns, but not some others, like timestamp, null fields (for Oracle),
> booleans, CLOB's, Decimals, etc.
>


Umm...huh? MDB2 has full support for BLOBs (and I assume CLOBS) as
well as dates, numbers, etc. Where are you looking for this? It *may*
not be implemented for each of the DB backends, but this can always be
improved.

> I have looked at an object by Daniel Convissor that does this type of
> abstraction correctly, for all of the above quirks (and more). Am I
> flogging a dead horse by implementing this as a separate layer in my db
> abstraction? or is it still necessary?


Could you let us know what this is?

>
> I have googled for information around this point, but can't find
> anything satisfactory. I have also tried looking through the API docs
> for MDB2 as well as the code, but could only find a couple of references
> to portability, namely in the terms described above.
>


MDB2 is all about portability, from the case of the field names to the
datatypes and all the way up to the schema. MDB2_Schema allows you to
specify your schema (and initial data) in an XML format in a DB
independant way and it will be handled right on all of the DB backends
it supports. It even supports finding differences in schemas and
dpeloying updates (IIRC).



If you find anything which is not implemented put a feature request
into the bug database. Or talk to Lukas and the other MDB2 devs to see
if what you're suggesting fits in (and isn't already implemented).
Patches are, of course, welcome. ;-) Don't waste your time doing it
yourself when most or all of it is done already.

--
Justin Patrin
Lukas Smith

2006-03-02, 3:56 am

Justin Patrin wrote:

>
> Umm...huh? MDB2 has full support for BLOBs (and I assume CLOBS) as
> well as dates, numbers, etc. Where are you looking for this? It *may*
> not be implemented for each of the DB backends, but this can always be
> improved.


http://cvs.php.net/viewcvs.cgi/*che.../datatypes.html

MDB2 does require that you use the appropriate datatypes inside the
RDBMS in order to do the mapping reliably. If you really care about
portability the best thing to do is to use MDB2_Schema to reverse
engineer your current schema into the MDB2 xml schema format. Then you
can recreate your database using compatible datatypes.

There might be little changes here and there. Like MySQL TIMESTAMP needs
to be converted to DATETIME etc.

regards,
Lukas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com