本文整理汇总了PHP中ARSelectFilter::setCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP ARSelectFilter::setCondition方法的具体用法?PHP ARSelectFilter::setCondition怎么用?PHP ARSelectFilter::setCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARSelectFilter
的用法示例。
在下文中一共展示了ARSelectFilter::setCondition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reorder
/**
* Reorder pages
*
* @role sort
*/
public function reorder()
{
$inst = StaticPage::getInstanceById($this->request->get('id'), StaticPage::LOAD_DATA);
$f = new ARSelectFilter();
$handle = new ARFieldHandle('StaticPage', 'position');
if ('down' == $this->request->get('order')) {
$f->setCondition(new MoreThanCond($handle, $inst->position->get()));
$f->setOrder($handle, 'ASC');
} else {
$f->setCondition(new LessThanCond($handle, $inst->position->get()));
$f->setOrder($handle, 'DESC');
}
$f->setLimit(1);
$s = ActiveRecordModel::getRecordSet('StaticPage', $f);
if ($s->size()) {
$pos = $inst->position->get();
$replace = $s->get(0);
$inst->position->set($replace->position->get());
$replace->position->set($pos);
$inst->save();
$replace->save();
return new JSONResponse(array('id' => $inst->getID(), 'order' => $this->request->get('order')), 'success');
} else {
return new JSONResponse(false, 'failure', $this->translate('_could_not_reorder_pages'));
}
}
示例2: getRecordSetByDeliveryZone
/**
* Load rates from known delivery zone
*
* @param DeliveryZone $deliveryZone
* @param bool $loadReferencedRecords
*
* @return ARSet
*/
public static function getRecordSetByDeliveryZone(DeliveryZone $deliveryZone = null, $loadReferencedRecords = array('Tax'))
{
$filter = new ARSelectFilter();
if (!$deliveryZone || $deliveryZone->isDefault()) {
$filter->setCondition(new IsNullCond(new ARFieldHandle(__CLASS__, "deliveryZoneID")));
} else {
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, "deliveryZoneID"), $deliveryZone->getID()));
}
return self::getRecordSet($filter, $loadReferencedRecords);
}
示例3: isValid
public function isValid($value)
{
ClassLoader::import('application.model.user.User');
$filter = new ARSelectFilter();
$cond = new EqualsCond(new ARFieldHandle('User', 'email'), $value);
$filter->setCondition($cond);
return ActiveRecordModel::getRecordCount('User', $filter) == 0;
}
示例4: getProductGroupsFilter
private static function getProductGroupsFilter(Product $product, $type)
{
$filter = new ARSelectFilter();
$filter->setOrder(new ARFieldHandle("ProductRelationshipGroup", "position"), 'ASC');
$filter->setCondition(new EqualsCond(new ARFieldHandle("ProductRelationshipGroup", "productID"), $product->getID()));
$filter->mergeCondition(new EqualsCond(new ARFieldHandle("ProductRelationshipGroup", "type"), $type));
return $filter;
}
示例5: loadItems
public function loadItems()
{
if (empty($this->items) && $this->isExistingRecord()) {
$filter = new ARSelectFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle('OrderedItem', 'shipmentID'), $this->getID()));
foreach (OrderedItem::getRecordSet('OrderedItem', $filter, array('Product', 'Category', 'DefaultImage' => 'ProductImage')) as $item) {
$this->items[] = $item;
}
}
}
示例6: getInstanceByDateTime
public static function getInstanceByDateTime($date, $time)
{
$f = new ARSelectFilter();
$f->setCondition(new AndChainCondition(array(eq(f('EyeExamSchedule.date'), $date), eq(f('EyeExamSchedule.time'), $time), isnull(f('EyeExamSchedule.eyeExamRequestID')))));
$s = self::getRecordSet('EyeExamSchedule', $f);
if (!$s->size()) {
return null;
}
return $s->get(0);
}
示例7: getUserAddress
public static function getUserAddress($className, $addressID, User $user)
{
$f = new ARSelectFilter();
$f->setCondition(new EqualsCond(new ARFieldHandle($className, 'ID'), $addressID));
$f->mergeCondition(new EqualsCond(new ARFieldHandle($className, 'userID'), $user->getID()));
$s = ActiveRecordModel::getRecordSet($className, $f, array('UserAddress'));
if (!$s->size()) {
throw new ARNotFoundException($className, $addressID);
}
return $s->get(0);
}
示例8: getInstanceByToken
public static function getInstanceByToken($token)
{
$filter = new ARSelectFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'token'), $token));
$recordSet = ActiveRecordModel::getRecordSet(__CLASS__, $filter);
if (!$recordSet->size()) {
return null;
} else {
return $recordSet->get(0);
}
}
示例9: insert
protected function insert()
{
// get max position
$f = new ARSelectFilter();
$f->setCondition($this->getParentCondition());
$f->setOrder(new ARFieldHandle(get_class($this), 'position'), 'DESC');
$f->setLimit(1);
$rec = ActiveRecord::getRecordSetArray(get_class($this), $f);
$position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 1;
$this->position->set($position);
return parent::insert();
}
示例10: getInstanceByName
public static function getInstanceByName($name)
{
$filter = new ARSelectFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle('Manufacturer', 'name'), $name));
$filter->setLimit(1);
$set = ActiveRecordModel::getRecordSet('Manufacturer', $filter);
if ($set->size() > 0) {
return $set->get(0);
} else {
return self::getNewInstance($name);
}
}
示例11: getRatingTypeFilter
private function getRatingTypeFilter(Product $product)
{
$path = $product->getCategory()->getPathNodeArray(Category::INCLUDE_ROOT_NODE);
$filter = new ARSelectFilter();
$filter->setOrder(new ARFieldHandle("Category", "lft"), 'ASC');
$filter->setOrder(new ARFieldHandle(__CLASS__, "position"), 'ASC');
$cond = new EqualsCond(new ARFieldHandle(__CLASS__, "categoryID"), $product->getCategory()->getID());
foreach ($path as $node) {
$cond->addOR(new EqualsCond(new ARFieldHandle(__CLASS__, "categoryID"), $node['ID']));
}
$filter->setCondition($cond);
return $filter;
}
示例12: getStateByIDAndCountry
/**
* Provides an additional verification that state belongs to the particular country
*
* @return ActiveRecord
*/
public static function getStateByIDAndCountry($stateID, $countryID)
{
$f = new ARSelectFilter();
$f->setCondition(new EqualsCond(new ARFieldHandle('State', 'ID'), $stateID));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('State', 'countryID'), $countryID));
$f->setLimit(1);
$states = ActiveRecordModel::getRecordSet('State', $f);
if ($states) {
return $states->get(0);
} else {
return null;
}
}
示例13: index
public function index()
{
$owner = ActiveRecordModel::getInstanceByID($this->getOwnerClass(), (int) $this->request->get('id'));
$filter = new ARSelectFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle($this->getModelClass(), $this->getForeignKeyName()), $owner->getID()));
$filter->setOrder(new ARFieldHandle($this->getModelClass(), 'position'));
$imageArray = ActiveRecordModel::getRecordSetArray($this->getModelClass(), $filter);
$response = new ActionResponse();
$response->set('form', $this->buildForm($owner->getID()));
$response->set('maxSize', ini_get('upload_max_filesize'));
$response->set('ownerId', $owner->getID());
$response->set('images', json_encode($imageArray));
return $response;
}
示例14: getTaxes
/**
* Get a list of existing taxes
*
* @param boolean $includeDisabled Include disabled taxes in this list
* @param TaxRate $doNotBelongToRate Don not belong to specified rate
* @param boolean $loadReferencedRecords Load referenced records
*
* @return ARSet
*/
public static function getTaxes(DeliveryZone $notUsedInThisZone = null, $loadReferencedRecords = false)
{
$filter = new ARSelectFilter();
$rates = TaxRate::getRecordSetByDeliveryZone($notUsedInThisZone);
if ($rates->getTotalRecordCount() > 0) {
$zoneRatesIDs = array();
foreach ($rates as $rate) {
$taxIDs[] = $rate->tax->get()->getID();
}
$notInCond = new NotINCond(new ARFieldHandle(__CLASS__, "ID"), $taxIDs);
$filter->setCondition($notInCond);
}
return self::getRecordSet($filter, $loadReferencedRecords);
}
示例15: getInstance
public static function getInstance(Product $product, Currency $currency)
{
$filter = new ARSelectFilter();
$cond = new EqualsCond(new ARFieldHandle('ProductPrice', 'productID'), $product->getID());
$cond->addAND(new EqualsCond(new ARFieldHandle('ProductPrice', 'currencyID'), $currency->getID()));
$filter->setCondition($cond);
$set = parent::getRecordSet('ProductPrice', $filter);
if ($set->size() > 0) {
$instance = $set->get(0);
} else {
$instance = self::getNewInstance($product, $currency);
}
return $instance;
}