Bad programming practices, example 1 post
As shocking as it seems, I sometimes don't follow smart programming practices. As a good example, I was refactoring the code that I use to keep track of results from the simulation baseball league I am the commissioner of. It's a PHP 4 app.
Specifically, I was changing database access to use the Active Reord pattern. Everything was going just fine until I did the update method. I forgot to specify the id of the record I was updating. Instead I overrote EVERY SINGLE ENTRY in the table. Of production data.
sigh
We have backups, but it will be some work to get back what I need back.
So the lesson? Backup the database before you do anything like I did OR have a development database you can use. One of the things I like about Ruby On Rails is that they build that capability right into it. You have a database config file that you tell where to find the development databases, production databases and test databases.