本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例11: getNewInstance
public static function getNewInstance(Category $category)
{
$catImage = ActiveRecord::getNewInstance(__CLASS__);
$catImage->category->set($category);
return $catImage;
}
示例12: getNewInstance
/**
* @return DeliveryZone
*/
public static function getNewInstance()
{
return ActiveRecord::getNewInstance(__CLASS__);
}
示例13: createChildProduct
public function createChildProduct()
{
$child = ActiveRecord::getNewInstance(__CLASS__);
$child->parent->set($this);
return $child;
}
示例14: getNewInstance
public static function getNewInstance(Product $product)
{
$image = ActiveRecord::getNewInstance(__CLASS__);
$image->product->set($product);
return $image;
}
示例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;
}