For an example of a PHP app that supports multiple databases, look at
"http://sourceforge.net/projects/gallery". It supports PostgreSQL,
MySQL, DB2, Oracle, and SQL Server (at least it will support SQL Server
in the next release, which will hopeffully be in the next few weeks or
month).
The trick is in abstraction. The non-uniform SQL (like
SUBSTR/SUBSTRING) is generated dynamically. In the Gallery2 source
tree, see "modules/core/classes/GalleryStorage/Db2Storage.class",
function "getFunctionSql()". There is an equivalent file for each
supported RDBM.
In addition, Gallery uses another PHP abstraction package called ADOdb,
see "http://sourceforge.net/projects/adodb".
Serge Rielau wrote:
Jo wrote:
Would you suggest the best way to port an application (that works with
MS SQL Server) would be to make the changes to the SQL statements so
that they would work with DB2. And consequently maintain 2 versions of
the application, one for DB2 and one for SQL Server? Is that the normal
way its done out there?
Thanks a lot !
It's not an easy one to answer and depends on teh complexity of your
SQL. Your typical PHP app is simple enough that there existsa shared
SQL92 way that works on both DBMS. So using the DB2 changes as a
feedback (and enforcing the required coding style changes) will save you
in the long run. These are often trivial requirements such as using
ansi-join syntax and the like.
If you app is more compelx (perhaps using triggers, procedures, etc.
then 2 versions is often what you end up with, sadly enough.
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/