本文整理汇总了PHP中ActiveRecordModel::deleteRecordSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::deleteRecordSet方法的具体用法?PHP ActiveRecordModel::deleteRecordSet怎么用?PHP ActiveRecordModel::deleteRecordSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::deleteRecordSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteInstancesByOrder
public function deleteInstancesByOrder(CustomerOrder $order)
{
// remove other ExpressCheckout instances for this order
$f = new ARDeleteFilter();
$f->setCondition(new EqualsCond(new ARFieldHandle('ExpressCheckout', 'orderID'), $order->getID()));
ActiveRecordModel::deleteRecordSet('ExpressCheckout', $f);
}
示例2: unsubscribe
public function unsubscribe()
{
$email = $this->request->get('email');
// delete from subscriber table
$f = new ARDeleteFilter(new EqualsCond(new ARFieldHandle('NewsletterSubscriber', 'email'), $email));
ActiveRecordModel::deleteRecordSet('NewsletterSubscriber', $f);
// add user to subscriber table
if ($user = User::getInstanceByEmail($email)) {
$s = NewsletterSubscriber::getNewInstanceByUser($user);
$s->isEnabled->set(false);
$s->save();
}
return new ActionResponse();
}
示例3: save
public function save()
{
ActiveRecordModel::beginTransaction();
$parent = Product::getInstanceByID($this->request->get('id'), true);
$items = json_decode($this->request->get('items'), true);
$types = json_decode($this->request->get('types'), true);
$variations = json_decode($this->request->get('variations'), true);
$existingTypes = $existingVariations = $existingItems = array();
$currency = $this->application->getDefaultCurrencyCode();
// deleted types
foreach ($types as $id) {
if (is_numeric($id)) {
$existingTypes[] = $id;
}
}
$parent->deleteRelatedRecordSet('ProductVariationType', new ARDeleteFilter(new NotINCond(new ARFieldHandle('ProductVariationType', 'ID'), $existingTypes)));
// deleted variations
foreach ($variations as $type => $typeVars) {
foreach ($typeVars as $id) {
if (is_numeric($id)) {
$existingVariations[] = $id;
}
}
}
$f = new ARDeleteFilter(new INCond(new ARFieldHandle('ProductVariation', 'typeID'), $existingTypes));
$f->mergeCondition(new NotINCond(new ARFieldHandle('ProductVariation', 'ID'), $existingVariations));
ActiveRecordModel::deleteRecordSet('ProductVariation', $f);
// deleted items
foreach ($items as $id) {
if (is_numeric($id)) {
$existingItems[] = $id;
}
}
$parent->deleteRelatedRecordSet('Product', new ARDeleteFilter(new NotINCond(new ARFieldHandle('Product', 'ID'), $existingItems)));
// load existing records
foreach (array('Types' => 'ProductVariationType', 'Variations' => 'ProductVariation', 'Items' => 'Product') as $arr => $class) {
$var = 'existing' . $arr;
$array = ${$var};
if ($array) {
ActiveRecordModel::getRecordSet($class, new ARSelectFilter(new INCond(new ARFieldHandle($class, 'ID'), $array)));
}
}
$idMap = array();
// save types
$request = $this->request->toArray();
foreach ($types as $index => $id) {
if (!is_numeric($id)) {
$type = ProductVariationType::getNewInstance($parent);
$idMap[$id] = $type;
} else {
$type = ActiveRecordModel::getInstanceByID('ProductVariationType', $id);
}
$type->setValueByLang('name', null, $request['variationType'][$index]);
$type->position->set($index);
if (!empty($request['typeLang_' . $id])) {
foreach ($request['typeLang_' . $id] as $field => $value) {
list($field, $lang) = explode('_', $field, 2);
$type->setValueByLang($field, $lang, $value);
}
}
$type->save();
}
// save variations
$tree = array();
$typeIndex = -1;
foreach ($variations as $typeID => $typeVars) {
$type = is_numeric($typeID) ? ActiveRecordModel::getInstanceByID('ProductVariationType', $typeID) : $idMap[$typeID];
$typeIndex++;
foreach ($typeVars as $index => $id) {
if (!is_numeric($id)) {
$variation = ProductVariation::getNewInstance($type);
$idMap[$id] = $variation;
} else {
$variation = ActiveRecordModel::getInstanceByID('ProductVariation', $id);
}
$variation->position->set($index);
$variation->setValueByLang('name', null, $request['variation'][$id]);
if (!empty($request['variationLang_' . $id])) {
foreach ($request['variationLang_' . $id] as $field => $value) {
list($field, $lang) = explode('_', $field, 2);
$variation->setValueByLang($field, $lang, $value);
}
}
$variation->save();
$tree[$typeIndex][] = $variation;
}
}
$images = array();
// save items
foreach ($items as $index => $id) {
if (!is_numeric($id)) {
$item = $parent->createChildProduct();
$idMap[$id] = $item;
} else {
$item = ActiveRecordModel::getInstanceByID('Product', $id);
}
$item->isEnabled->set(!empty($request['isEnabled'][$id]));
if (!$request['sku'][$index]) {
$request['sku'][$index] = $item->sku->get();
}
//.........这里部分代码省略.........
示例4: deleteRecords
public function deleteRecords(ARSelectFilter $filter)
{
$del = new ARDeleteFilter($filter->getCondition());
ActiveRecordModel::deleteRecordSet($this->className, $del, $this->getReferencedData());
}