During development, I include the following:
my.cnf:
[mysqld]
log_slow_queries = /var/log/mysql/mysql-slow.log
sql_mode = STRICT_ALL_TABLES
STRICT_ALL_TABLES
Enable strict mode for all storage engines. Invalid data values: rejected.
For example, consider the following:
CREATE TABLE `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL,
`date` datetime NOT NULL
);
INSERT INTO `posts` (`title`, `date`) VALUES ('Title text', NULL);
If you use STRICT_ALL_TABLES sql_mode, mysql will not throw an error when trying to insert a value NULLinto a column NOT NULL, instead mysql will insert default data depending on the type of column. for example for a datetime column NOT NULL, when you insert a value NULL, mysql will use the default datetime value for 0000-00-00 00-00-00.
Strict mode, in a sense, is like raising the level of report_ error and displaying errors in PHP, which is best practice during development.
ini_set('error_reporting', -1);
ini_set('display_errors', true);
, , , ?