3
我在使用自定義表格收集日期過濾器時遇到困難。已經搜索here和here和其他一些地方,但仍然無法得到我所需要的。問題是我無法將NULL
值添加到結果集中。Magento,按日期期限過濾收集幷包含空值
到目前爲止,經過多次試驗和錯誤的測試我當前的代碼:
$myBannersCollection = Mage::getModel('banners/bannersadmin')->getCollection()
->addfieldtofilter('banner_prod_id',$currentProdID)
->addfieldtofilter('banner_start_date',
array(
array('from' => Mage::getModel('core/date')->gmtDate()),
'banner_start_date' => null))
->addfieldtofilter('banner_end_date',
array(
array('gteq' => Mage::getModel('core/date')->gmtDate()),
'null' => true)
);
var_dump((string) $myBannersCollection->getselect());
此代碼。OUPUTS下面的SQL代碼片段:
SELECT `main_table`.*
FROM `dts_banners_admin` AS `main_table`
WHERE (banner_prod_id = '16')
AND (((banner_start_date >= '2012-11-28 14:39:13') OR (banner_start_date='')))
AND (banner_end_date IS NULL)
嘗試了好幾種不同的選項來添加NULL
條件,但沒有我可以得到像這樣的東西:
SELECT `main_table`.*
FROM `dts_banners_admin` AS `main_table`
WHERE (banner_prod_id = '16')
AND (((banner_start_date>='2012-11-28 14:39:13') OR (banner_start_date IS NULL)))
AND ((banner_end_date >= '2012-11-28 14:39:13') OR (banner_end_date IS NULL))
PS: Magento在addfieldtofilter
上有BETWEEN
運營商嗎?
**至** <=> ** <=** not **> = ** – HoangHieu