I’ve been in the position of having to take an unnormalized database that had virtually no data validation or standardization in place, and migrating it to a completely different, normalized schema. I wielded the power of regular expressions (regex) to help me through the process.
Archive for August, 2009
Dealing with NULL Inserts in PHP
Sunday, August 23rd, 2009
In the past, I hadn’t given much thought to NULL vs. empty string when dealing with blank fields in my database. If something was empty, I would just set it to $field = ''; and insert it. This is bad for a few reasons—but most importantly the database doesn’t see an empty string as an empty field, but rather a string with no length. When using COUNT, it sees empty strings and other data as one and the same.
Once I started using NULL values in my DBs, I found the PHP more cumbersome when doing inserts.