CREATE TABLE IF NOT EXISTS `ws_cash` ( `cash_id` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(11) DEFAULT NULL COMMENT 'refer to accounts.account_id of employee who do this.', `order_id` int(11) DEFAULT NULL COMMENT 'refer to esm_orders.order_id', `cash_in` decimal(20,9) NOT NULL DEFAULT '0.000000000' COMMENT 'cash in. as absolute number', `cash_out` decimal(20,9) NOT NULL DEFAULT '0.000000000' COMMENT 'cash out. as absolute number', `cash_date` bigint(20) DEFAULT NULL COMMENT 'cash record date.', PRIMARY KEY (`cash_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='contain cash in or out records.' AUTO_INCREMENT=1 ;
when i set the number to order_id for example order_id = 5. It can insert 5 into field order_id correctly. but when i set order_id = null or unset it, it should be null but it is not. It is becomes 0.
if you don't pass a column and a value to insert(), it will not be part of the INSERT statement. So it's either your code, or your DB engine. And you're not going to find out which if you don't debug.