本文整理汇总了PHP中ActiveRecord::deleteRecordSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::deleteRecordSet方法的具体用法?PHP ActiveRecord::deleteRecordSet怎么用?PHP ActiveRecord::deleteRecordSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::deleteRecordSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* @todo Rewrite this to use ARUpdateFilter or simply an SQL query to update all values
As in the original bug report:
The update query for merging value 799 into 808 would look something like this:
UPDATE SpecificationItem
LEFT JOIN SpecificationItem AS SecondItem ON SpecificationItem.productID=SecondItem.productID AND SecondItem.specFieldValueID=808
SET SpecificationItem.specFieldValueID=808
WHERE SpecificationItem.specFieldValueID=799 AND SecondItem.specFieldValueID IS NULL
- it would only update products that do not have value 808 already set (otherwise the query would error because of duplicate SpecificationItem records).
The remaining records with value 799 will be automatically removed (cascade) when SpecFieldValue 799 is deleted.
*/
private function mergeFields()
{
if (empty($this->mergedFields)) {
return true;
}
$itemClass = call_user_func(array($this->getFieldClass(), 'getSelectValueClass'));
$valueColumn = call_user_func(array($itemClass, 'getValueIDColumnName'));
$specificationItemSchema = self::getSchemaInstance($itemClass);
$foreignKeys = $specificationItemSchema->getForeignKeyList();
$specFieldReferenceFieldName = '';
foreach ($foreignKeys as $foreignKey) {
if ($foreignKey->getForeignClassName() == get_class($this)) {
$specFieldReferenceFieldName = $foreignKey->getName();
break;
}
}
$thisSchema = self::getSchemaInstance(get_class($this));
$primaryKeyList = $thisSchema->getPrimaryKeyList();
$promaryKey = array_shift($primaryKeyList);
$mergedFieldsIDs = array();
foreach ($this->mergedFields as $mergedField) {
$mergedFieldsIDs[] = $mergedField->getID();
}
$inAllItemsExceptThisCondition = new INCond(new ARFieldHandle(get_class($this), $promaryKey->getName()), $mergedFieldsIDs);
$mergedFieldsIDs[] = $this->getID();
$inAllItemsCondition = new INCond(new ARFieldHandle($itemClass, $specFieldReferenceFieldName), $mergedFieldsIDs);
// Create filters
$mergedSpecificationItemsFilter = new ARSelectFilter();
$mergedSpecificationItemsFilter->setCondition($inAllItemsCondition);
// Using IGNORE I'm ignoring duplicate primary keys. Those rows that violate the uniqueness of the primary key are simply not saved
// Then later I just delete these records and the merge is complete.
$sql = 'UPDATE IGNORE ' . $itemClass . ' SET ' . $valueColumn . ' = ' . $this->getID() . ' ' . $mergedSpecificationItemsFilter->createString();
self::getLogger()->logQuery($sql);
self::executeUpdate($sql);
$mergedSpecFieldValuesDeleteFilter = new ARDeleteFilter();
$mergedSpecFieldValuesDeleteFilter->setCondition($inAllItemsExceptThisCondition);
ActiveRecord::deleteRecordSet(get_class($this), $mergedSpecFieldValuesDeleteFilter);
}
示例2: processMass
/**
* @role mass
*/
public function processMass()
{
$filter = $this->getSelectFilter();
$act = $this->request->get('act');
$field = array_pop(explode('_', $act, 2));
if ('move' == $act) {
new ActiveGrid($this->application, $filter, $this->getClassName());
$cat = Category::getInstanceById($this->request->get('categoryID'), Category::LOAD_DATA);
$update = new ARUpdateFilter();
$update->setCondition($filter->getCondition());
$update->addModifier('Product.categoryID', $cat->getID());
$update->joinTable('ProductPrice', 'Product', 'productID AND (ProductPrice.currencyID = "' . $this->application->getDefaultCurrencyCode() . '")', 'ID');
ActiveRecord::beginTransaction();
ActiveRecord::updateRecordSet('Product', $update, Product::LOAD_REFERENCES);
Category::recalculateProductsCount();
ActiveRecord::commit();
return new JSONResponse(array('act' => $this->request->get('act')), 'success', $this->translate('_move_succeeded'));
}
// remove design themes
if ('theme' == $act && !$this->request->get('theme')) {
ClassLoader::import('application.model.presentation.CategoryPresentation');
ActiveRecord::deleteRecordSet('CategoryPresentation', new ARDeleteFilter($filter->getCondition()), null, array('Product', 'Category'));
return new JSONResponse(array('act' => $this->request->get('act')), 'success', $this->translate('_themes_removed'));
}
$params = array();
if ('manufacturer' == $act) {
$params['manufacturer'] = Manufacturer::getInstanceByName($this->request->get('manufacturer'));
} else {
if ('price' == $act || 'inc_price' == $act) {
$params['baseCurrency'] = $this->application->getDefaultCurrencyCode();
$params['price'] = $this->request->get($act);
$params['currencies'] = $this->application->getCurrencySet();
$params['inc_price_value'] = $this->request->get('inc_price_value');
$params['inc_quant_price'] = $this->request->get('inc_quant_price');
} else {
if ('addRelated' == $act) {
$params['relatedProduct'] = Product::getInstanceBySKU($this->request->get('related'));
if (!$params['relatedProduct']) {
return new JSONResponse(0);
}
} else {
if ($this->request->get('categoryID')) {
$params['category'] = Category::getInstanceById($this->request->get('categoryID'), Category::LOAD_DATA);
} else {
if ('theme' == $act) {
ClassLoader::import('application.model.presentation.CategoryPresentation');
$params['theme'] = $this->request->get('theme');
} else {
if ('shippingClass' == $act) {
$params['shippingClass'] = $this->request->get('shippingClass');
} else {
if ('taxClass' == $act) {
$params['taxClass'] = $this->request->get('taxClass');
}
}
}
}
}
}
}
$response = parent::processMass($params);
if ($this->request->get('categoryID')) {
Category::recalculateProductsCount();
}
return $response;
}
示例3: removeByZone
public static function removeByZone(DeliveryZone $zone)
{
$filter = new ARDeleteFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'deliveryZoneID'), $zone->getID()));
return ActiveRecord::deleteRecordSet(__CLASS__, $filter);
}