News for hackers. Stuff that matters.
Re:Ask YC: Those using PHP, what do you use for talking to y... by alex_c on Monday August 11, 2008 @01:19PM (#273125)
I am aware that I might regret that decision IF I have to move my app to a different database.

Even so, I don't think such a move would be that painful. I've taken great care to isolate all SQL queries from the rest of the code, and to keep them all in one place. I also have queries which I've had to optimize for the specific database I'm using (MySQL). I doubt an out-of-the-box DAL would be able to help with those in the current incarnation, or eliminate the need to rewrite them if the database changes.

The biggest challenge I can foresee is if they grow to the point where I need multiple databases in order to scale. I don't have enough experience yet to know whether existing frameworks would help in such a scenario, or just get in the way. But changing from MySQL to PostgreSQL? I'm fairly confident I can live with that.

But first and foremost, they're small-to-medium projects (in terms of code size), with relatively simple data models, and a single developer. I wouldn't advocate this approach for large projects.

Re:Ask YC: Those using PHP, what do you use for talking to y... by jm4 on Monday August 11, 2008 @04:18PM (#273284)
The problem with moving to a different database when you've used the database specific functions in PHP is that you have to use completely different functions for the new database. Moving from MySQL to PostgreSQL isn't so bad because those functions are fairly consistent. I think in most cases you just change mysql_ to pg_.

Moving to something like Oracle or ODBC is a major task. You end up having to rewrite quite a bit of code even if you've isolated your queries. I had to learn this the hard way through experience and thought I'd share so someone else could avoid the hassle. The app that I had to move was very small and about the last thing I thought I'd have to spend much time maintaining. Six months later I was wasting half a day rewriting database code. Not sure why I would get modded down for this.