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


PHP Currency::save方法代码示例

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


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

示例1: edit

 /**
  * Update existing route
  *
  * @param void
  * @return null
  */
 function edit()
 {
     if ($this->active_currency->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $currency_data = $this->request->post('currency');
     if (!is_array($currency_data)) {
         $currency_data = array('name' => $this->active_currency->getName(), 'code' => $this->active_currency->getCode(), 'default_rate' => $this->active_currency->getDefaultRate());
     }
     // if
     $this->smarty->assign('currency_data', $currency_data);
     if ($this->request->isSubmitted()) {
         $this->active_currency->setAttributes($currency_data);
         $save = $this->active_currency->save();
         if ($save && !is_error($save)) {
             flash_success('Currency ":name" has been updated', array('name' => $this->active_currency->getName()));
             $this->redirectTo('admin_currencies');
         } else {
             $this->smarty->assign('errors', $save);
         }
         // if
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:31,代码来源:CurrenciesAdminController.class.php

示例2: handleUpdate

 function handleUpdate()
 {
     global $current_user;
     if ($current_user->is_admin) {
         if (isset($_POST['id']) && !empty($_POST['id']) && isset($_POST['name']) && !empty($_POST['name']) && isset($_POST['rate']) && !empty($_POST['rate']) && isset($_POST['symbol']) && !empty($_POST['symbol'])) {
             $ids = $_POST['id'];
             $names = $_POST['name'];
             $symbols = $_POST['symbol'];
             $rates = $_POST['rate'];
             $isos = $_POST['iso'];
             $size = sizeof($ids);
             if ($size != sizeof($names) || $size != sizeof($isos) || $size != sizeof($symbols) || $size != sizeof($rates)) {
                 return;
             }
             require_once 'modules/Currencies/Currency.php';
             $temp = new Currency();
             for ($i = 0; $i < $size; $i++) {
                 $temp->id = $ids[$i];
                 $temp->name = $names[$i];
                 $temp->symbol = $symbols[$i];
                 $temp->iso4217 = $isos[$i];
                 $temp->conversion_rate = $rates[$i];
                 $temp->save();
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:27,代码来源:ListCurrency.php

示例3: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $super = User::getByUsername('super');
     $bobby = UserTestHelper::createBasicUser('bobby');
     $sarah = UserTestHelper::createBasicUser('sarah');
     self::$superUserId = $super->id;
     self::$bobbyUserId = $bobby->id;
     self::$sarahUserId = $sarah->id;
     $currency = Currency::makeBaseCurrency();
     assert($currency->code == 'USD');
     // Not Coding Standard
     self::$baseCurrencyId = $currency->id;
     $currency = new Currency();
     $currency->code = 'EUR';
     $currency->rateToBase = 2;
     assert($currency->save());
     // Not Coding Standard
     self::$eurCurrencyId = $currency->id;
     $values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
     $fieldData = CustomFieldData::getByName('WorkflowTestDropDown');
     $fieldData->serializedData = serialize($values);
     $saved = $fieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
     $fieldData = CustomFieldData::getByName('WorkflowTestRadioDropDown');
     $fieldData->serializedData = serialize($values);
     $saved = $fieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
     $fieldData = CustomFieldData::getByName('WorkflowTestMultiDropDown');
     $fieldData->serializedData = serialize($values);
     $saved = $fieldData->save();
     assert($saved);
     // Not Coding Standard
     $values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
     $fieldData = CustomFieldData::getByName('WorkflowTestTagCloud');
     $fieldData->serializedData = serialize($values);
     $saved = $fieldData->save();
     assert($saved);
     // Not Coding Standard
     $loaded = ContactsModule::loadStartingData();
     assert($loaded);
     // Not Coding Standard
     $contactStates = ContactState::getByName('New');
     self::$newState = $contactStates[0];
     $contactStates = ContactState::getByName('In progress');
     self::$inProgressState = $contactStates[0];
     self::$groupTest = new Group();
     self::$groupTest->name = 'test';
     $saved = self::$groupTest->save();
     assert($saved);
     // Not Coding Standard
     $group = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $saved = $group->save();
     assert($saved);
     // Not Coding Standard
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:60,代码来源:WorkflowActionAttributeFormResolveValueTest.php

示例4: parse

 public static function parse($date)
 {
     $date = date('Y-m-d', strtotime($date));
     require_once 'sources/CurrencySourceBase.php';
     /** @var CurrencyRaw[][] $data */
     $data = [];
     $codes = [];
     foreach (static::$sources as $lang => $sourceClass) {
         require_once 'sources/' . $sourceClass . '.php';
         /** @var CurrencySourceBase $source */
         $source = new $sourceClass();
         $data[$lang] = $source->parse($date);
         $codes = array_merge($codes, array_keys($data[$lang]));
     }
     //        CVarDumper::dump($data, 3, 1);return;
     if (isset($data['ru'][self::UAH_CODE])) {
         $costRubUah = $data['ru'][self::UAH_CODE]->cost;
     } else {
         throw new Exception('Cost RUB:UAH not found');
     }
     $tr = Yii::app()->db->beginTransaction();
     Currency::model()->deleteAll('date = :date', [':date' => $date]);
     foreach ($codes as $code) {
         try {
             /** @var CurrencyRaw $ru */
             /** @var CurrencyRaw $ua */
             $ru = empty($data['ru']) == false && empty($data['ru'][$code]) == false ? $data['ru'][$code] : null;
             $ua = empty($data['ua']) == false && empty($data['ua'][$code]) == false ? $data['ua'][$code] : null;
             if (!$ru && !$ua) {
                 continue;
             }
             $currency = new Currency();
             $currency->date = $date;
             $currency->num_code = $code;
             $currency->char_code = $ru ? $ru->char_code : $ua->char_code;
             $currency->name_ru = $ru ? $ru->name : null;
             $currency->name_ua = $ua ? $ua->name : null;
             $currency->nominal_ru = $ru ? $ru->nominal : null;
             $currency->nominal_ua = $ua ? $ua->nominal : null;
             $currency->cost_rub = $ru ? $ru->cost / $currency->nominal_ru : null;
             $currency->cost_uah = $ua ? $ua->cost / $currency->nominal_ua : null;
             $currency->diff = $ru && $ua ? $currency->cost_uah / $costRubUah - $currency->cost_rub : null;
             if ($currency->save(true) == false) {
                 //                    CVarDumper::dump([$currency->getAttributes(), $currency->errors], 3, 1);
                 //                    $tr->rollback();
                 //                    throw new Exception('Con not save currency in DB');
             }
         } catch (Exception $ex) {
             continue;
         }
     }
     $tr->commit();
     return true;
 }
开发者ID:VitProg,项目名称:nas-test-app,代码行数:54,代码来源:CurrencyParser.php

示例5: tearDown

 public function tearDown()
 {
     global $sugar_config;
     $this->currency_system->symbol = $this->backupSymbol;
     $this->currency_system->save(false);
     $sugar_config['default_currency_symbol'] = $this->backupSymbol;
     format_number(0, 0, 0, array('currency_id' => $this->currency_51568->id, 'currency_symbol' => $this->currency_51568->symbol));
     format_number(0, 0, 0, array('currency_id' => -99, 'currency_symbol' => $this->currency_51568->getDefaultCurrencySymbol()));
     $this->currency_51568->mark_deleted($this->currency_51568->id);
     SugarTestHelper::tearDown();
     get_number_seperators(true);
 }
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:12,代码来源:Bug51568Test.php

示例6: actionCreate

 public function actionCreate()
 {
     $model = new Currency();
     if (isset($_POST['Currency'])) {
         $model->attributes = $_POST['Currency'];
         if ($model->validate() && $model->save()) {
             $this->redirect(array('index'));
         }
     }
     $statusOptions = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled'));
     $this->render('create', array('model' => $model, 'statusOptions' => $statusOptions));
 }
开发者ID:damnpoet,项目名称:yiicart,代码行数:12,代码来源:CurrenciesController.php

示例7: store

 /**
  * Store a newly created currency in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Currency::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $currency = new Currency();
     $currency->name = Input::get('name');
     $currency->shortname = Input::get('shortname');
     $currency->save();
     Audit::logaudit('Currency', 'create', 'created: ' . $currency->name);
     return Redirect::route('currencies.index');
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:18,代码来源:CurrenciesController.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Currency();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Currency'])) {
         $model->attributes = $_POST['Currency'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:emisdb,项目名称:gena_0,代码行数:17,代码来源:CurrencyController.php

示例9: createCurrency

 public static function createCurrency($attributes)
 {
     $currency = new Currency();
     if (!empty($attributes['id'])) {
         $currency->new_with_id = true;
         $currency->id = $attributes['id'];
         unset($attributes['id']);
     }
     foreach ($attributes as $attribute => $value) {
         $currency->{$attribute} = $value;
     }
     $currency->save();
     self::$createdCurrencies[] = $currency;
     return $currency;
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:15,代码来源:SugarTestCurrencyUtilities.php

示例10: testCreateCurrencyAndIsActiveByDefaultAndSettingActiveToFalse

 public function testCreateCurrencyAndIsActiveByDefaultAndSettingActiveToFalse()
 {
     $currency = new Currency();
     $currency->code = 'EUR';
     $currency->rateToBase = 2;
     $this->assertTrue($currency->save());
     $currency->forget();
     $currency = Currency::getByCode('EUR');
     $this->assertEquals(1, $currency->active);
     $currency->active = false;
     $this->assertTrue($currency->save());
     $currency->forget();
     $currency = Currency::getByCode('EUR');
     $this->assertEquals(0, $currency->active);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:15,代码来源:CurrencyTest.php

示例11: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Currency();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Currency'])) {
         $model->attributes = $_POST['Currency'];
         $model->created_on = date('Y-m-d');
         $model->created_by = Yii::app()->user->id;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Saved successfully');
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:optimosolution,项目名称:jasorbd,代码行数:20,代码来源:CurrencyController.php

示例12: getCurrencies

 protected function getCurrencies()
 {
     $wikipedia = $this->web->get(sfConfig::get('app_source_currencies'), null, array('User-Agent' => 'Steve Lacey <steve@stevelacey.net>', 'Cache-Control' => 'no-cache'));
     $xml = new SimpleXMLElement($wikipedia->getResponseText());
     $article = $xml->page->revision->text;
     $table = substr($article, strpos($article, '{|'), strpos($article, '|}') - strpos($article, '{|'));
     foreach (explode('-| ', str_replace(array('[', ']', "\n"), '', $table)) as $row) {
         $row = explode(' || ', trim($row, '| '));
         if (isset($row[2], $row[4]) && is_numeric($row[2])) {
             $currency = new Currency();
             $currency->setCode(sfConfig::get('app_currency_alias_' . $row[0], $row[0]));
             $currency->setNumber($row[1]);
             $currency->setDigits(ceil($row[2]));
             $currency->setName($row[3]);
             $currency->save();
         }
     }
 }
开发者ID:asaraf28,项目名称:CurrencyConverter,代码行数:18,代码来源:getCurrenciesTask.class.php

示例13: execute

 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // update rates
     list($rates) = $this->getRates();
     foreach ($rates as $rateInfo) {
         list($code, $rate) = $rateInfo;
         $currency = Doctrine_Core::getTable('Currency')->findOneByCode($code);
         if (!$currency) {
             $currency = new Currency();
             $currency->code = $code;
         }
         $currency->rate = $rate;
         $currency->save();
     }
     $this->logSection('payment', 'Exchange rates have been updated.');
 }
开发者ID:schmittjoh,项目名称:jmsPaymentPlugin,代码行数:19,代码来源:jmsPaymentPluginUpdateRatesTask.class.php

示例14: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aCurrency !== null) {
             if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
                 $affectedRows += $this->aCurrency->save($con);
             }
             $this->setCurrency($this->aCurrency);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->statesScheduledForDeletion !== null) {
             if (!$this->statesScheduledForDeletion->isEmpty()) {
                 StateQuery::create()->filterByPrimaryKeys($this->statesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->statesScheduledForDeletion = null;
             }
         }
         if ($this->collStates !== null) {
             foreach ($this->collStates as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:homer6,项目名称:blank_altumo,代码行数:54,代码来源:BaseCountry.php

示例15: doSave

 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      ConnectionInterface $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see save()
  */
 protected function doSave(ConnectionInterface $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aProduct !== null) {
             if ($this->aProduct->isModified() || $this->aProduct->isNew()) {
                 $affectedRows += $this->aProduct->save($con);
             }
             $this->setProduct($this->aProduct);
         }
         if ($this->aAttributeAv !== null) {
             if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) {
                 $affectedRows += $this->aAttributeAv->save($con);
             }
             $this->setAttributeAv($this->aAttributeAv);
         }
         if ($this->aCurrency !== null) {
             if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) {
                 $affectedRows += $this->aCurrency->save($con);
             }
             $this->setCurrency($this->aCurrency);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:bcbrr,项目名称:LegacyProductAttributes,代码行数:53,代码来源:LegacyProductAttributeValuePrice.php


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