2011-01-13 65 views
1


我有一個數據庫字段的問題。有了這個代碼:Magento,1分貝字段未保存

$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 

有什麼想法?

編輯:解決的辦法是:在我的strtotime表達

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

退房的 「S」。

回答

2

我知道許多屬性允許在寫入之前和閱讀之後進行某種格式化。您是否嘗試將該值設置爲unix時間戳?

+0

OMG !!!事實證明,我的時間表達中缺少「s」,它必須是「月」,而不是「月」。 你的回答並不是真正的解決方案,但是你讓我覺得它很棒,它幫助我找到它,所以,這裏有一些要點;) thanx clockworkgeek,看到你身邊 – OSdave 2011-01-13 13:50:00