コード例 #1
0
 public function actionIndex()
 {
     $request = App::core()->request;
     $response = App::core()->response;
     $cache = App::core()->cache;
     try {
         $params = array('cost' => $request->get('cost'), 'currency' => $request->get('currency'));
         $cacheConfig = array();
         if ($cache instanceof Cache) {
             $cacheConfig = array('host' => $cache->getHost(), 'port' => $cache->getPort());
         }
         $converter = new CurrencyConverter($params, $cacheConfig);
         $response->set($converter->get());
     } catch (CurrencyException $e) {
         $response->setError($e->getMessage());
     } catch (ConverterException $e) {
         $response->setError($e->getMessage());
     } catch (\Exception $e) {
         $response->setError($e->getMessage());
     }
     $log = new CurrencyLog();
     $log->create($request);
     $response->send();
 }
コード例 #2
0
 public function save()
 {
     $db = App::core()->db;
     return $db->insert($this->getTable(), (array) $this);
 }