I'm refactoring the code, from mysql extension to pdo's. Existing db schema is such way that for almost all columns in 100 pulse tables are having NOT NULL constraint. Due to this constraint I'm very often facing following error while inserting and updating the data.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'some-column-name' cannot be null
Obligations:
So I'm looking for a generic solution where empty string is inserted instead of NULL that will be addressed for all PDO statements. I'm using this PDO helper class.
When you declare your column, do it with NOT NULL DEFAULT ''. This way, MySQL will replace a NULL value with an empty string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With