James Cox wrote:
> > I'm planning to write a database application for MySQL, and then port it
> > PostrgeSQL.
> > Is there any library or class that could help me to write/maintain just
> > source code for both MySQL and PostgreSQL ?
> I think your best (if not the only) option in PHP is Metabase.
> <snip spam>
> you could also use PEAR (http://pear.php.net/) which has a more than
> adequate abstraction layer for various databases.
PEAR does not offer a good means of writing portable database
applications because it does not have data type abstraction support.
This is important because different databases represent data types
differently. For instance, Oracle, unlike other databases, does not have
individual time and date field types, only a single type that represents
both a full timestamp with time and date. This means that if you just
want to store a date on the field you have to use the whole timestamp
field and discard the time part. Metabase handles that for you. PEAR
does not provide any support for this level of database portability.
I think this is an important point to mention about this limitatation of
PEAR because I noticed that a lot of people that use PEAR did not know
about it because they develop applications that only deal with text and
integers that need little or no conversion, besides any eventual
As soon they need to use other data types like date and time, when they
need to run their applications in different databases, they realize that
PEAR was not a good idea because, unlike Metabase, it doesn't handle
datatype representation format differences.
This may not be a problem for you James, but it is a problem for a lot
of database developers that really care about portability because it
costs a lot of time and money to maintain the applications that need to
work with different databases if you have to tweak your application to
handle the differences of the databases.
This is the main reason why Java JDBC provide such an high level of
database application portability, that in the PHP world only has
parallel with Metabase.
> But, I doubt even metabase can rewrite your SQL queries for you so that it's
> optimized for postgres AND mysql (and any other option you would like to
Metabase does not rewrite queries. You need to know Metabase better. It
just converts datatypes of between a database independent format that
applications use and the native database datatype format, if and when
the develop wants that.
> you're much better off either picking one DB system, or use both but
> maintain seperate SQL for each, to provide full optimization.
If the original poster would not mind to have the major headache of
doing that, he would not have posted, don't you think?
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php