本文整理汇总了PHP中ActiveRecordModel::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::save方法的具体用法?PHP ActiveRecordModel::save怎么用?PHP ActiveRecordModel::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
$this->load();
$this->userAddress->get()->load();
$this->userAddress->get()->save();
return parent::save();
}
示例2: save
public function save()
{
if (!$this->orderedItem->get()->customerOrder->get()->isFinalized->get()) {
$this->updatePriceDiff();
}
return parent::save();
}
示例3: save
protected function save(ActiveRecordModel $listGroup)
{
$validator = $this->buildValidator();
if ($validator->isValid()) {
$listGroup->loadRequestData($this->request);
$listGroup->save();
return new JSONResponse(array('ID' => $listGroup->getID(), 'data' => $listGroup->toArray()), 'success');
} else {
return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure');
}
}
示例4: save
/**
* Save user in the database
*/
public function save($forceOperation = null)
{
// auto-generate password if not set
if (!$this->password->get()) {
$this->setPassword($this->getAutoGeneratedPassword());
}
return parent::save($forceOperation);
}
示例5: save
public function save()
{
if ($this->isModified()) {
@unlink($this->userGroup->get()->getRoleCacheFile());
}
return parent::save();
}
示例6: save
public function save($forceOperation = 0)
{
// do not allow 0 rates
if (!$this->rate->get()) {
$this->rate->set(1);
}
self::deleteCache();
return parent::save($forceOperation);
}
示例7: saveRecord
protected function saveRecord(ActiveRecordModel $record)
{
$record->save();
}
示例8: save
public function save($forceOperation = null)
{
if (!$this->currency->get()) {
$this->currency->set($this->realCurrency->get());
$this->amount->set($this->realAmount->get());
}
// encrypt card number
if ($this->ccLastDigits->isModified()) {
$this->ccLastDigits->set($this->encrypt($this->ccLastDigits->get()));
}
return parent::save($forceOperation);
}
示例9: save
public function save()
{
BusinessRuleController::clearCache();
return parent::save();
}
示例10: save
public function save($allowEmpty = false)
{
if (!$this->orderedItems) {
$this->loadItems();
}
// remove zero-count items
foreach ($this->orderedItems as $item) {
if (!$item->count->get()) {
$this->removeItem($item);
}
}
$isModified = false;
foreach ($this->orderedItems as $item) {
if ($item->isDeleted()) {
$this->removeItem($item);
}
}
// delete removed items
if ($this->removedItems) {
foreach ($this->removedItems as $item) {
$item->delete();
$isModified = true;
}
$this->removedItems = array();
$this->resetShipments();
}
if ($this->orderedItems) {
$this->getCurrency();
foreach ($this->orderedItems as $item) {
if ($item->isModified()) {
if (!$this->isExistingRecord()) {
parent::save();
}
if ($item->save()) {
$isModified = true;
}
}
$item->markAsLoaded();
}
}
// If shipment is modified
if ($this->isFinalized->get()) {
if ($this->shipments) {
foreach ($this->shipments as $shipment) {
if ($shipment->isModified()) {
$isModified = true;
break;
}
}
}
}
if ($isModified) {
$this->getCurrency();
// reorder shipments when cart items are modified
$this->resetShipments();
$this->totalAmount->set($this->getTotal(true));
} else {
if (!$this->isShippingRequired()) {
//$this->shippingAddress->setNull();
}
}
if ($this->isModified() || $isModified) {
$this->serializeShipments();
}
if (!$this->isFinalized->get() && !$this->orderedItems && !$allowEmpty && !self::$isEmptyAllowed) {
$this->delete();
return false;
}
if ($this->user->get()) {
$this->user->get()->invalidateSessionCache();
}
return parent::save();
}
示例11: importAttributes
protected function importAttributes(ActiveRecordModel $instance, $record, $fields, $attrIdentifier = 'eavField')
{
if (isset($fields[$attrIdentifier])) {
$impReq = new Request();
$fieldClass = ucfirst($attrIdentifier);
$valueClass = 'eavField' == $attrIdentifier ? 'EavValue' : $fieldClass . 'Value';
foreach ($fields[$attrIdentifier] as $specFieldID => $csvIndex) {
if (empty($record[$csvIndex])) {
continue;
}
$attr = ActiveRecordModel::getInstanceByID($fieldClass, $specFieldID, ActiveRecord::LOAD_DATA);
if ($attr->isSimpleNumbers()) {
$impReq->set($attr->getFormFieldName(), (double) $record[$csvIndex]);
} else {
if ($attr->isSelector()) {
if ($attr->isMultiValue->get()) {
$values = explode(',', $record[$csvIndex]);
} else {
$values = array($record[$csvIndex]);
}
foreach ($values as $fieldValue) {
$fieldValue = trim($fieldValue);
$f = new ARSelectFilter(new LikeCond(MultilingualObject::getLangSearchHandle(new ARFieldHandle($valueClass, 'value'), $this->application->getDefaultLanguageCode()), $fieldValue . '%'));
$f->setLimit(1);
if (!($value = $attr->getRelatedRecordSet($valueClass, $f)->shift())) {
$value = call_user_func_array(array($valueClass, 'getNewInstance'), array($attr));
if ($attr->type->get() == EavFieldCommon::TYPE_NUMBERS_SELECTOR) {
$value->value->set($fieldValue);
} else {
$value->setValueByLang('value', $this->application->getDefaultLanguageCode(), $fieldValue);
}
$value->save();
}
if (!$attr->isMultiValue->get()) {
$impReq->set($attr->getFormFieldName(), $value->getID());
} else {
$impReq->set($value->getFormFieldName(), true);
}
}
} else {
$impReq->set($attr->getFormFieldName(), $record[$csvIndex]);
}
}
}
$instance->loadRequestData($impReq);
$instance->save();
}
}
示例12: save
public function save($downloadable = false)
{
$this->removeDeletedItems();
// make sure the shipment doesn't consist of downloadable files only
if (!$this->isShippable() && !$this->order->get()->isFinalized->get()) {
//return false;
}
// reset amounts...
// $this->amount->set(0);
// $this->shippingAmount->set(0);
// $this->taxAmount->set(0);
// ... and recalculated them
$this->recalculateAmounts();
// set shipping data
$rate = $this->getSelectedRate();
if ($rate) {
$serviceId = $rate->getServiceID();
if (is_numeric($serviceId)) {
$this->shippingService->set(ShippingService::getInstanceByID($serviceId));
} else {
$this->shippingService->set(null);
$this->shippingServiceData->set(serialize($rate));
}
}
// Update order status if to reflect it's shipments statuses
if (!$downloadable && $this->isShippable() && $this->order->get()->isFinalized->get()) {
$this->order->get()->updateStatusFromShipments(!$this->isExistingRecord());
}
parent::save();
// save ordered items
foreach ($this->items as $item) {
if (!$item->isDeleted()) {
$item->shipment->set($this);
$item->customerOrder->set($this->order->get());
$item->save();
}
}
// save taxes
foreach ($this->getTaxes() as $tax) {
if ($tax->amount->get()) {
$tax->save();
} else {
$tax->delete();
}
}
}
示例13: save
public function save()
{
parent::save();
$this->order->get()->registerFixedDiscount($this);
}
示例14: save
public function save($forceOperation = 0)
{
self::deleteCache();
return parent::save($forceOperation);
}
示例15: save
public function save($forceOperation = 0)
{
parent::save($forceOperation);
$this->updateRoles();
}