Things you might find useful

Archive for the ‘Code’ Category

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.

Read the rest of this entry »

Tags: ,
Posted in Code | View Comments