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


PHP ActiveRecord::getNewInstance方法代码示例

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


在下文中一共展示了ActiveRecord::getNewInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNewInstance

 /**
  * Create new user group
  *
  * @param DeliveryZone $deliveryZone Delivery zone instance
  * @param Tax $tax Tax type
  * @param float $rate Rate in percents
  * @return TaxRate
  */
 public static function getNewInstance($name, $description = '')
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->name->set($name);
     $instance->description->set($description);
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:15,代码来源:UserGroup.php

示例2: getNewInstance

 /**
  * @return DeliveryZoneCountry
  */
 public static function getNewInstance(DeliveryZone $zone, $countryCode)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->deliveryZone->set($zone);
     $instance->countryCode->set($countryCode);
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:10,代码来源:DeliveryZoneCountry.php

示例3: getNewInstance

 /**
  * @return DeliveryZoneState
  */
 public static function getNewInstance(DeliveryZone $zone, $mask)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->deliveryZone->set($zone);
     $instance->mask->set($mask);
     return $instance;
 }
开发者ID:saiber,项目名称:www,代码行数:10,代码来源:DeliveryZoneCityMask.php

示例4: getNewInstance

 /**
  * Associate new role to user group
  *
  * @param UserGroup $userGroup User group
  * @param Role $role Associate group with this role
  * @return Tax
  */
 public static function getNewInstance(UserGroup $userGroup, Role $role)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->userGroup->set($userGroup);
     $instance->role->set($role);
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:14,代码来源:AccessControlAssociation.php

示例5: getNewInstance

 /**
  * Create new shipping rate instance
  *
  * @param ShippingService $shippingService Shipping service instance
  * @param float $rangeStart Lower range limit
  * @param float $rangeEnd Higher range limit
  * @return ShippingRate
  */
 public static function getNewInstance(ShippingService $shippingService, $rangeStart, $rangeEnd)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->shippingService->set($shippingService);
     $instance->setRangeStart($rangeStart);
     $instance->setRangeEnd($rangeEnd);
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:16,代码来源:ShippingRate.php

示例6: getNewInstance

 /**
  * Create new tax rate
  *
  * @param DeliveryZone $deliveryZone Delivery zone instance
  * @param Tax $tax Tax type
  * @param float $rate Rate in percents
  * @return TaxRate
  */
 public static function getNewInstance(DeliveryZone $deliveryZone = null, Tax $tax, $rate)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     if ($deliveryZone) {
         $instance->deliveryZone->set($deliveryZone);
     }
     $instance->tax->set($tax);
     $instance->rate->set($rate);
     return $instance;
 }
开发者ID:saiber,项目名称:www,代码行数:18,代码来源:TaxRate.php

示例7: add

 /**
  * @role create
  */
 public function add()
 {
     try {
         $newCurrency = ActiveRecord::getNewInstance('Currency');
         $newCurrency->setId($this->request->get('id'));
         $newCurrency->save(ActiveRecord::PERFORM_INSERT);
         return new JSONResponse($newCurrency->toArray());
     } catch (Exception $exc) {
         return new JSONResponse(0);
     }
 }
开发者ID:saiber,项目名称:www,代码行数:14,代码来源:CurrencyController.php

示例8: getNewInstance

 public static function getNewInstance(RecurringProductPeriod $recurringProductPeriod, OrderedItem $item, $setupPrice = null, $periodPrice = null, $rebillCount = null)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->orderedItem->set($item);
     $instance->setRecurringProductPeriod($recurringProductPeriod);
     // call after orderedItem is added!
     $instance->periodLength->set($recurringProductPeriod->periodLength->get());
     $instance->periodType->set($recurringProductPeriod->periodType->get());
     if ($setupPrice !== null) {
         $instance->setupPrice->set($setupPrice);
     }
     if ($periodPrice !== null) {
         $instance->periodPrice->set($periodPrice);
     }
     if ($rebillCount !== null) {
         $instance->rebillCount->set($rebillCount);
     }
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:19,代码来源:RecurringItem.php

示例9: add

 /**
  * @role create
  */
 public function add()
 {
     try {
         $newCurrency = ActiveRecord::getNewInstance('Currency');
         $newCurrency->setId($this->request->get('id'));
         $config = $this->getApplication()->getConfig();
         // if can use external currency rate source
         if ($config->get('CURRENCY_RATE_UPDATE')) {
             // get exchange rate from external currency rate source
             $source = CurrencyRateSource::getInstance($this->application, null, array($newCurrency->getID()));
             $rate = $source->getRate($newCurrency->getID());
             if ($rate != null) {
                 $newCurrency->rate->set($rate);
             }
         }
         $newCurrency->save(ActiveRecord::PERFORM_INSERT);
         return new JSONResponse($newCurrency->toArray());
     } catch (Exception $exc) {
         return new JSONResponse(0);
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:24,代码来源:CurrencyController.php

示例10: testSerializeSpeed

 public function testSerializeSpeed()
 {
     for ($k = 1; $k <= 10; $k++) {
         $record = ActiveRecord::getNewInstance('SerializedModel');
         $record->setID($k);
         $record->name->set('some name ' . $k);
         $record->save();
     }
     ActiveRecord::clearPool();
     // fetch from database
     $fetchTime = microtime(true);
     $set = ActiveRecord::getRecordSet('SerializedModel', new ARSelectFilter());
     $fetchTime = microtime(true) - $fetchTime;
     $serialized = serialize($set);
     ActiveRecord::clearPool();
     // unserialize
     $serTime = microtime(true);
     $set = unserialize($serialized);
     $serTime = microtime(true) - $serTime;
     $this->assertTrue($serTime < $fetchTime);
 }
开发者ID:saiber,项目名称:www,代码行数:21,代码来源:SerializeTest.php

示例11: getNewInstance

 public static function getNewInstance(Category $category)
 {
     $catImage = ActiveRecord::getNewInstance(__CLASS__);
     $catImage->category->set($category);
     return $catImage;
 }
开发者ID:saiber,项目名称:www,代码行数:6,代码来源:CategoryImage.php

示例12: getNewInstance

 /**
  * @return DeliveryZone
  */
 public static function getNewInstance()
 {
     return ActiveRecord::getNewInstance(__CLASS__);
 }
开发者ID:saiber,项目名称:www,代码行数:7,代码来源:DeliveryZone.php

示例13: createChildProduct

 public function createChildProduct()
 {
     $child = ActiveRecord::getNewInstance(__CLASS__);
     $child->parent->set($this);
     return $child;
 }
开发者ID:saiber,项目名称:livecart,代码行数:6,代码来源:Product.php

示例14: getNewInstance

 public static function getNewInstance(Product $product)
 {
     $image = ActiveRecord::getNewInstance(__CLASS__);
     $image->product->set($product);
     return $image;
 }
开发者ID:saiber,项目名称:www,代码行数:6,代码来源:_ProductImage.php

示例15: getNewInstance

 /**
  * Create new shipping class
  *
  * @param string $$defaultLanguageName Type name spelled in default language
  * @return TaxClass
  */
 public static function getNewInstance($defaultLanguageName)
 {
     $instance = ActiveRecord::getNewInstance(__CLASS__);
     $instance->setValueByLang('name', null, $defaultLanguageName);
     return $instance;
 }
开发者ID:saiber,项目名称:www,代码行数:12,代码来源:TaxClass.php


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