【发布时间】:2012-01-07 21:44:37
【问题描述】:
我正在处理一个 codeigniter 项目,我正在尝试解决一个 sql 问题。我有一个查询更新了我表中的日期字段,但它根本没有更新它。
我有这张桌子
CREATE TABLE `Customer` (
`customer_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`first_name` varchar(55) NOT NULL DEFAULT '',
`last_name` varchar(55) NOT NULL DEFAULT '',
`city` varchar(255) DEFAULT '',
`state` char(2) DEFAULT '',
`zip` int(5) DEFAULT NULL,
`title` varchar(255) NOT NULL DEFAULT '',
`image` varchar(255) DEFAULT '',
`blurb` blob,
`end_date` date DEFAULT NULL,
`goal` int(11) DEFAULT NULL,
`paypal_acct_num` int(11) DEFAULT NULL,
`progress_bar` enum('full','half','none') DEFAULT NULL,
`page_views` int(11) NOT NULL DEFAULT '0',
`total_pages` int(11) NOT NULL DEFAULT '0',
`total_conversions` int(11) NOT NULL DEFAULT '0',
`total_given` int(11) NOT NULL DEFAULT '0',
`conversion_percentage` int(11) NOT NULL DEFAULT '0',
`avg_contribution` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`customer_id`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
当我运行这个查询来插入数据时,它运行良好并将日期设置为2012-11-01
INSERT INTO `Customer` (`first_name`, `last_name`, `end_date`) VALUES ('John', 'Smith2', '2012-11-01');
然后我得到 customer_id 并尝试运行此查询
UPDATE `Customer` SET `end_date` = '2012-14-01' WHERE `customer_id` = '18';
并将日期 end_date 字段设置为0000-00-00。
为什么将结束日期更改为 0000-00-00 而不是 2012-14-01?
【问题讨论】:
标签: php sql codeigniter