当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecord::getInstanceById方法代码示例

本文整理汇总了PHP中ActiveRecord::getInstanceById方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getInstanceById方法的具体用法?PHP ActiveRecord::getInstanceById怎么用?PHP ActiveRecord::getInstanceById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::getInstanceById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:13,代码来源:Language.php

示例2: save

 public function save()
 {
     ActiveRecord::beginTransaction();
     $image = null;
     try {
         $image = ActiveRecord::getInstanceById($this->getModelClass(), $this->request->get('imageId'), true);
         $multilingualFields = array("title");
         $image->setValueArrayByLang($multilingualFields, $this->application->getDefaultLanguageCode(), $this->application->getLanguageArray(true), $this->request);
         $image->save();
         if ($_FILES['image']['tmp_name']) {
             $resizer = new ImageManipulator($_FILES['image']['tmp_name']);
             if (!$resizer->isValidImage()) {
                 throw new InvalidImageException();
             }
             if (!$image->resizeImage($resizer)) {
                 throw new ImageResizeException();
             }
         }
     } catch (InvalidImageException $exc) {
         $error = $this->translate('_err_not_image');
     } catch (ImageResizeException $exc) {
         $error = $this->translate('_err_resize');
     } catch (Exception $exc) {
         $error = $this->translate('_err_not_found ' . get_class($exc));
     }
     $response = new ActionResponse();
     if (isset($error)) {
         ActiveRecord::rollback();
         $result = array('error' => $error);
     } else {
         ActiveRecord::commit();
         $result = $image->toArray();
     }
     $this->setLayout('iframeJs');
     $response->set('ownerId', $this->request->get('ownerId'));
     $response->set('imageId', $this->request->get('imageId'));
     $response->set('result', @json_encode($result));
     return $response;
 }
开发者ID:saiber,项目名称:livecart,代码行数:39,代码来源:ObjectImageController.php

示例3: setEnabled

 /**
  * Sets if currency is enabled
  * @role status
  * @return ActionResponse
  */
 public function setEnabled()
 {
     $id = $this->request->get('id');
     $curr = ActiveRecord::getInstanceById('Currency', $id, true);
     $curr->isEnabled->set((int) (bool) $this->request->get("status"));
     $curr->save();
     return new JSONResponse(array('currency' => $curr->toArray()), 'success');
 }
开发者ID:saiber,项目名称:livecart,代码行数:13,代码来源:CurrencyController.php

示例4: restoreInstance

 public function restoreInstance()
 {
     $instance = ActiveRecord::getInstanceById($this->instanceClassName, $this->instanceId);
     return $instance;
 }
开发者ID:saiber,项目名称:www,代码行数:5,代码来源:ARSerializedReference.php


注:本文中的ActiveRecord::getInstanceById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。