本文整理汇总了PHP中Condition::mergeFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Condition::mergeFromArray方法的具体用法?PHP Condition::mergeFromArray怎么用?PHP Condition::mergeFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::mergeFromArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadCategoryPathsForArray
public static function loadCategoryPathsForArray(&$productArray)
{
foreach ($productArray as $product) {
$cond = lte('Category.lft', $product['Category']['lft']);
$cond->addAnd(gte('Category.rgt', $product['Category']['rgt']));
$conditions[] = $cond;
}
$filter = select(Condition::mergeFromArray($conditions, true));
$filter->setOrder(f('Category.lft'));
$categories = ActiveRecord::getRecordSetArray('Category', $filter);
foreach ($productArray as &$product) {
$product['Categories'] = array();
$names = array();
foreach ($categories as &$category) {
if ($category['lft'] <= $product['Category']['lft'] && $category['rgt'] >= $product['Category']['rgt']) {
$product['Categories'][] =& $category;
$names[] = $category['name_lang'];
}
}
array_shift($names);
$product['category_path'] = implode(' > ', $names);
$product['category_path_slash'] = implode(' / ', $names);
$product['category_name'] = count($names) > 0 ? array_pop($names) : '';
}
}
示例2: select
function select()
{
return new ARSelectFilter(Condition::mergeFromArray(func_get_args()));
}
示例3: loadSubConditions
public static function loadSubConditions(ARSet $conditionSet)
{
$cond = array();
foreach ($conditionSet as $condition) {
if ($condition->hasSubConditions()) {
$cond[] = $condition->getChildNodeCondition();
}
}
if (!$cond) {
return new ARSet();
}
$f = new ARSelectFilter(Condition::mergeFromArray($cond, true));
$subConditions = ActiveRecordModel::getRecordSet(__CLASS__, $f);
foreach ($subConditions as $condition) {
$condition->parentNode->get()->registerSubCondition($condition);
}
return $subConditions;
}
示例4: getCondition
/**
* Create an ActiveRecord Condition object to use for product selection
*
* @return Condition
*/
public function getCondition()
{
$specField = $this->filterGroup->get()->specField->get();
// number range
if ($specField->isSimpleNumbers()) {
$field = new ARExpressionHandle($this->getJoinAlias() . '.value');
$conditions = array();
if ($this->rangeStart->get()) {
$conditions[] = new EqualsOrMoreCond($field, $this->rangeStart->get());
}
if ($this->rangeEnd->get()) {
$conditions[] = new EqualsOrLessCond($field, $this->rangeEnd->get());
}
$cond = Condition::mergeFromArray($conditions);
} elseif ($specField->isDate()) {
$field = new ARExpressionHandle($this->getJoinAlias() . '.value');
$conditions = array();
if ($this->rangeDateStart->get()) {
$conditions[] = new EqualsOrMoreCond($field, $this->rangeDateStart->get());
}
if ($this->rangeDateEnd->get()) {
$conditions[] = new EqualsOrLessCond($field, $this->rangeDateEnd->get());
}
$cond = Condition::mergeFromArray($conditions);
} else {
throw new ApplicationException('Filter type not supported');
}
return $cond;
}
示例5: getDateCondition
protected function getDateCondition(ARFieldHandle $handle)
{
$conds = array();
if ($this->from) {
$conds[] = new EqualsOrMoreCond($handle, $this->from);
}
if ($this->to) {
$conds[] = new EqualsOrLessCond($handle, $this->to);
}
if ($conds) {
return Condition::mergeFromArray($conds);
}
}