Example #1
0
 /**
  * Сохранить
  * 
  * @param \Application_Model_Currency $currency Модель currency
  */
 public function save(Application_Model_Currency $currency)
 {
     $data = ['title' => $currency->getTitle(), 'name' => $currency->getName(), 'providerCurrencyId' => $currency->getProviderCurrencyId()];
     if (null === ($id = $currency->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, ['id = ?' => $id]);
     }
 }
 public function save(Application_Model_Currency $currency)
 {
     if ($currency->def) {
         $currency->active = 1;
     }
     $data = array('id' => $currency->id, 'code' => $currency->code, 'rate' => $currency->rate, 'def' => $currency->def, 'active' => $currency->active);
     if ($data['def']) {
         $this->getDbTable()->update(array('def' => 0), array('id <> ?' => $currency->id));
     }
     if (null === ($id = $currency->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
 }