NYCPHP Meetup

NYPHP.org

[nycphp-talk] Trying to decide between MDB2 and PHP PDO

Hans Zaunere lists at zaunere.com
Fri Jun 26 01:19:34 EDT 2009


> Hi, I work with Kevin. Our application needs to run on both mySQL and
Oracle
> so we are looking for portability. We currently are using PEAR DB and we
are
> looking into moving to MDB2 or PDO so we thought it would be a good idea
to
> test performance before we make a decision. Amazing what you find when you
> dig ...

If you actually do expect to need agile portability between databases, the
application level programming interface is secondary.  Really think about
your schema (column types, return types, constraints, etc) and queries (join
behavior, optimizations, transactions, limitations, etc).

Most performance impact will come with the right indexes/queries/etc. and
retrieval/storage strategies - not a couple of function calls here or there.
Plus, it's generally much easier to scale up web servers than databases, so
that'll be the first pressure point to worry about.

For a "database abstraction" layer, write a simple class and interface to
wrap the database's native drivers.  In 2 hours you can write a lightweight
class around mysqli and OCI that fits your application perfectly, gives a
consistent interface, actually increases application flexibility and overall
portability, and gives your code a solid code base to be built on top of.
Plus it'll probably be faster.  There's not really a lot of sense in my
opinion to put another layer of code between what your application wants to
do, and what the database actually can do.

H





More information about the talk mailing list