本文整理汇总了PHP中ActiveRecord::deleteByID方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::deleteByID方法的具体用法?PHP ActiveRecord::deleteByID怎么用?PHP ActiveRecord::deleteByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::deleteByID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteById
public static function deleteById($id)
{
self::deleteCache();
// make sure the language record exists
$inst = ActiveRecord::getInstanceById('Language', $id, true);
// make sure it's not the default currency
if (true != $inst->isDefault->get()) {
ActiveRecord::deleteByID('Language', $id);
return true;
} else {
return false;
}
}
示例2: setAttribute
/**
* Sets specification attribute value by mapping product, specification field, and
* assigned value to one record (atomic item)
*
* @param iEavSpecification $specification Specification item value
*/
public function setAttribute(iEavSpecification $newSpecification)
{
$specField = $newSpecification->getFieldInstance();
$itemClass = $specField->getSelectValueClass();
if ($this->owner->isExistingRecord() && isset($this->attributes[$newSpecification->getFieldInstance()->getID()]) && ($itemClass == $specField->getSpecificationFieldClass() && $newSpecification->getValue()->isModified())) {
// Delete old value
ActiveRecord::deleteByID($itemClass, $this->attributes[$specField->getID()]->getID());
// And create new
$this->attributes[$specField->getID()] = call_user_func_array(array($itemClass, 'getNewInstance'), array($this->owner, $specField, $newSpecification->getValue()->get()));
} else {
$this->attributes[$specField->getID()] = $newSpecification;
}
unset($this->removedAttributes[$specField->getID()]);
}
示例3: registerLastViewed
public static function registerLastViewed($item, $instance = null)
{
$item['position'] = time();
$filter = new ARSelectFilter();
foreach (array('menuID', 'productID', 'userID', 'orderID') as $fieldName) {
if (array_key_exists($fieldName, $item)) {
$filter->setCondition(eq(f(__CLASS__ . '.' . $fieldName), $item[$fieldName]));
break;
// should have only one identificator.
}
}
$items = self::getUserToolbarItems(null, $filter);
if (count($items) > 0) {
// update postion to $item['position'] for first found existing record
$update = new ARUpdateFilter();
$update->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'ID'), $items[0]['ID']));
$update->addModifier('position', $item['position']);
ActiveRecord::updateRecordSet(__CLASS__, $update);
} else {
// create new
self::getNewInstance($item)->save();
}
$filter = new ARSelectFilter();
$filter->setLimit(999, BackendToolbarItem::LAST_VIEWED_COUNT);
$items = self::getUserToolbarItems(array(BackendToolbarItem::TYPE_PRODUCT, BackendToolbarItem::TYPE_USER, BackendToolbarItem::TYPE_ORDER), $filter, 'DESC');
if (count($items) > 0) {
foreach ($items as $item) {
ActiveRecord::deleteByID(__CLASS__, $item['ID']);
}
}
return true;
}