本文整理汇总了PHP中ARSelectFilter::addField方法的典型用法代码示例。如果您正苦于以下问题:PHP ARSelectFilter::addField方法的具体用法?PHP ARSelectFilter::addField怎么用?PHP ARSelectFilter::addField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARSelectFilter
的用法示例。
在下文中一共展示了ARSelectFilter::addField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSubscriptionStatusImpl
private function getSubscriptionStatusImpl($forceRecheck)
{
if ($this->isRecurring->get() == false) {
return false;
// not even a recurring order.
}
$rebillsLeft = $this->rebillsLeft->get();
if ($rebillsLeft == -1 || $rebillsLeft > 0) {
return self::ACTIVE_SUBSCRIPTION;
}
// if order is invoice
$filter = new ARSelectFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'parentID'), $this->getID()));
$filter->addField('(SELECT SUM(IF(CustomerOrder.rebillsLeft >= 0, CustomerOrder.rebillsLeft, 0 )))', '', 'rebillsLeft');
$filter->addField('(SELECT SUM(IF(CustomerOrder.rebillsLeft = -1, 1, 0 )))', '', 'isInfinite');
$filter->setGrouping(new ARFieldHandle(__CLASS__, 'parentID'));
$data = ActiveRecordModel::getRecordSetArray(__CLASS__, $filter);
if (count($data) == 1 && ($data[0]['isInfinite'] > 0 || $data[0]['rebillsLeft'] > 0)) {
return self::ACTIVE_SUBSCRIPTION;
}
return false;
}
示例2: info
public function info()
{
ClassLoader::importNow("application.helper.getDateFromString");
$product = Product::getInstanceById($this->request->get('id'), ActiveRecord::LOAD_DATA, array('DefaultImage' => 'ProductImage', 'Manufacturer', 'Category'));
$thisMonth = date('m');
$lastMonth = date('Y-m', strtotime(date('m') . '/15 -1 month'));
$periods = array('_last_1_h' => "-1 hours | now", '_last_3_h' => "-3 hours | now", '_last_6_h' => "-6 hours | now", '_last_12_h' => "-12 hours | now", '_last_24_h' => "-24 hours | now", '_last_3_d' => "-3 days | now", '_this_week' => "w:Monday | now", '_last_week' => "w:Monday ~ -1 week | w:Monday", '_this_month' => $thisMonth . "/1 | now", '_last_month' => $lastMonth . "-1 | " . $lastMonth . "/1", '_this_year' => "January 1 | now", '_last_year' => "January 1 last year | January 1", '_overall' => "now | now");
$purchaseStats = array();
$prevCount = 0;
foreach ($periods as $key => $period) {
list($from, $to) = explode(' | ', $period);
$cond = new EqualsCond(new ARFieldHandle('OrderedItem', 'productID'), $product->getID());
if ('now' != $from) {
$cond->addAND(new EqualsOrMoreCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($from)));
}
if ('now' != $to) {
$cond->addAnd(new EqualsOrLessCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($to)));
}
$f = new ARSelectFilter($cond);
$f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true));
$f->removeFieldList();
$f->addField('SUM(OrderedItem.count)');
$query = new ARSelectQueryBuilder();
$query->setFilter($f);
$query->includeTable('OrderedItem');
$query->joinTable('CustomerOrder', 'OrderedItem', 'ID', 'customerOrderID');
if (($count = array_shift(array_shift(ActiveRecordModel::getDataBySql($query->getPreparedStatement(ActiveRecord::getDBConnection()))))) && ($count > $prevCount || '_overall' == $key)) {
$purchaseStats[$key] = $count;
}
if ($count > $prevCount) {
$prevCount = $count;
}
}
$response = new ActionResponse();
$response->set('together', $product->getProductsPurchasedTogether(10));
$response->set('product', $product->toArray());
$response->set('purchaseStats', $purchaseStats);
return $response;
}
示例3: getActiveProductManufacturerFirstLetters
public static function getActiveProductManufacturerFirstLetters()
{
$letters = $ids = array();
$f = new ARSelectFilter();
$sql = !self::getApplication()->getConfig()->get('MANUFACTURER_PAGE_DISPLAY_ACTIVE') ? 'SELECT DISTINCT(ID) as manufacturerID FROM Manufacturer ' . $f->createString() . ' GROUP BY manufacturerID' : 'SELECT DISTINCT(manufacturerID) FROM Product ' . $f->createString() . ' GROUP BY manufacturerID';
foreach (ActiveRecordModel::getDataBySQL($sql) as $row) {
$ids[] = $row['manufacturerID'];
}
$f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids));
$f->addField('UPPER(LEFT(TRIM(Manufacturer.name),1))', '', 'FirstLetter');
$f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
$f->setOrder(new ARFieldHandle('Manufacturer', 'name'));
$manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', $f);
foreach ($manufacturers as $item) {
$letters[$item['FirstLetter']] = $item['FirstLetter'];
}
return $letters;
}