本文整理匯總了PHP中Varien_Db_Adapter_Interface::getDatePartSql方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Db_Adapter_Interface::getDatePartSql方法的具體用法?PHP Varien_Db_Adapter_Interface::getDatePartSql怎麽用?PHP Varien_Db_Adapter_Interface::getDatePartSql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Db_Adapter_Interface
的用法示例。
在下文中一共展示了Varien_Db_Adapter_Interface::getDatePartSql方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getFinalPriceExpr
/**
* Get final price expression
*
* @param Varien_Db_Adapter_Interface $write
* @param Zend_Db_Expr $price
* @param Zend_Db_Expr $specialPrice
* @param Zend_Db_Expr $specialFrom
* @param Zend_Db_Expr $specialTo
*
* @return Zend_Db_Expr
*/
public function getFinalPriceExpr($write, $price, $specialPrice, $specialFrom, $specialTo)
{
if ($this->getVersionHelper()->isGe1600()) {
$currentDate = $write->getDatePartSql('cwd.website_date');
if ($this->getVersionHelper()->isGe1700()) {
$groupPrice = $write->getCheckSql('gp.price IS NULL', "{$price}", 'gp.price');
}
$specialFromDate = $write->getDatePartSql($specialFrom);
$specialToDate = $write->getDatePartSql($specialTo);
$specialFromUse = $write->getCheckSql("{$specialFromDate} <= {$currentDate}", '1', '0');
$specialToUse = $write->getCheckSql("{$specialToDate} >= {$currentDate}", '1', '0');
$specialFromHas = $write->getCheckSql("{$specialFrom} IS NULL", '1', "{$specialFromUse}");
$specialToHas = $write->getCheckSql("{$specialTo} IS NULL", '1', "{$specialToUse}");
$finalPrice = $write->getCheckSql("{$specialFromHas} > 0 AND {$specialToHas} > 0" . " AND {$specialPrice} < {$price}", $specialPrice, $price);
if ($this->getVersionHelper()->isGe1700()) {
$finalPrice = $write->getCheckSql("{$groupPrice} < {$finalPrice}", $groupPrice, $finalPrice);
}
} else {
$currentDate = new Zend_Db_Expr('cwd.date');
$finalPrice = new Zend_Db_Expr("IF(IF({$specialFrom} IS NULL, 1, " . "IF(DATE({$specialFrom}) <= {$currentDate}, 1, 0)) > 0 AND IF({$specialTo} IS NULL, 1, " . "IF(DATE({$specialTo}) >= {$currentDate}, 1, 0)) > 0 AND {$specialPrice} < {$price}, " . "{$specialPrice}, {$price})");
}
return $finalPrice;
}