So I am writing this series to help others that might stumble upon this entry as a starting point for building a good web application from the start. Let me tell you that there is nothing worse then building up a web application just to figure out you need to make a change that requires a change in 8 other sections.
So a bit of background. I am the lead developer for Photoblog. Before doing Photoblog, I had around 5-6 years of PHP experience. I made many mistakes and have learned a lot from them. So please use this and the others I write to learn from my mistakes.
So my first and foremost advice is to create a wrapper class around the database driver. If you were one of the poor souls that didn't do this and wanted to move from php's mysql to their mysqli class then you had to change a ton of mysql_* commands. So that is where the benefits of a wrapper class comes in. When you need to make some changes, you just do it in the wrapper class.
Basically to make a simple mysql query this is what I do
$DB = new Database;
$DB->connect();
$DB->query("SELECT * FROM table WHERE id=1 LIMIT 1");
$DB->fetch_array();
Do you see the benefits to that? You might at first think that it is overkill to do this but its really not. You can do so much with a wrapper class. If you want to run an explain on each query or find the time to complete each query you just add it in the query() function in the wrapper class.
Doing this will save you time in the end.
I use to write sql queries like this
mysql_query("query here") or die(mysql_error());
So now I just do
$DB->query("query here");
In that query() function I can create my own error page if sql errors out. For Photoblog what I do is if the user is an admin it shows the SQL query and the error. If its a normal user it will email the admins the SQL error and just show a error page that the user can understand and say a email has been sent out.
So as you can see there are major benefits to creating a wrapper class for mysql. This is just the tip of the iceberg of what you can do with a wrapper class.