Magento,1 db字段未保存

时间:2011-01-13 12:27:38

标签: magento model save


我对DB的一个字段有问题。使用此代码:

$expireMonth = Mage::getStoreConfig('points_options/config_points/expiration_period', Mage::app()->getStore()->getId());

if (!is_null($expireMonth) && ($expireMonth > 0)) {
    $expireDate = date("Y-m-d H:i:s", strtotime("+" . $expireMonth . " month"));
} else {
    $expireDate = NULL;
}

//die($expireDate);
//store in points history table
$this->_pointsModel->setCustomerId($this->_customer->getId())
                   ->setOrdersId('welcome')
                   ->setPointsPending($pointsForNewCustomer)
                   ->setPointsComment(Mage::helper('points')->__('welcome points'))
                   ->setDateAdded(date('Y-m-d H:i:s'))
                   ->setPointsStatus(2)//confirmed
                   ->setPointsType('WE')
                   ->setStoreId(Mage::app()->getStore()->getId())
                   ->setExpireDate($expireDate)
                   ->save();

expire_date外,每个字段都保存在表格中。如果我取消注释die($expireData),我会看到正确的值,例如2012-01-13 13:21:12。该字段定义为:

`expire_date` datetime NULL

有什么想法?

编辑:解决方案是:

$expireDate = date("Y-m-d H:i:s", strtotime("+" . $expireMonth . " months"));

在我的strtotime表达中查看“s”。

1 个答案:

答案 0 :(得分:2)

我知道许多属性允许在写入之前和阅读之后进行某种格式化。您是否尝试将该值设置为unix时间戳?