views:

37

answers:

2

I am making a function (PHP). In this function it basically uses the dbms specified and connects, submits the appropriate query, <insert my problem here>, and disconnects. DBMSs include MySQL, MSSQL, Postgres, and Oracle.

I am assuming that outside of this function, the user would not have access to specified DMBS, so whatever results I get from it I need to convert to something usable like a regular PHP variable/array/object.

I don't know the best way to do this (and have only had extended experience with MySQL), so I would like to know how going about handling each return so that they all come out to PHP relatively the same. I would extremely appreciate an example in any case.

A: 

Maybe you want to look at PDO.

Michal Čihař
+5  A: 

Unless you are doing this to learn, I recommend looking into PDO. It comes built in since PHP 5, and can handle the DBMSs you mention.

There's also ADODb that supports even more DBMSs but has the disadvantage of not being a native, compiled part of PHP.

In my opinion, it's not worth writing an own database wrapper anymore in 2010 for production use. There are too many high-quality industry-standard solutions around.

Pekka