>From my experience the answer is "it depends". If you use the PHP ODBC functions, you'll pretty much be able to communicate with any database that supports ODBC access without having to change your code. However you will be restricted to the basic ODBC functions and database specific optimizations and features will be unavailable to you. However another approach depending on how much time your willing to put into it would be to setup your project in a modularized way such that with a simple configuration change (either via a database or a flat file) you can direct your application to call pre-defined database functions based on the configuration setting. So for a MySQL database you set the configuration to "MySQL" and when your app calls for a database function it is directed to the specific PHP MySQL database functions. Obviously this would require writing a lot more code as you'd have to do this for each type of database you want to support, but if done properly once you do it you can re-use it for any project you require it for. I haven't researched it myself, but I'm sure that there are probably frameworks out there that take care of that functionality for you, but for me most of them have a lot of features I don't need or have a steep learning curve for the amount of time I'm willing to put into them. YMMV. I know my response is vague at best, but then again this is a fairly common subject that is best answered by you doing a little research via Google and testing out some of the available solutions to see what works best for you. -Tim
________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian Dailey Sent: Wednesday, February 14, 2007 10:19 AM To: NYPHP Talk Subject: [nyphp-talk] Writing Database Agnostic Code A lot of the books and other material that I've been reading talk about database abstraction - developing your application so that you can use different database backends without significant (or maybe any) changes to your code. Pear::DB seems to really do a good job with this. However... In the past, I've always used MySQL or Oracle, but mostly MySQL. Each SQL distribution has its own peculiar ways of doing some things, and I know that using some of the MySQL functions makes the code far easier to write and also optimizes the speed of the query. So my question boils down to this: how does one balance writing code that works regardless of the backend and still keep things optimized for speed and clarity? Are there any generalized tips that any of you can share from your experiences?
_______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
