Created
September 17, 2020 02:56
-
-
Save rombyar/4a6efbeab91879d049ecf0e66382a6fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') or exit('No direct script access allowed'); | |
class Update_rate extends CI_Controller | |
{ | |
public function index(){ | |
$content = file_get_contents("https://api.exchangeratesapi.io/latest?base=USD"); | |
$result=json_decode($content, true); | |
$array_payment = ['paypal', 'perfectmoney', 'webmoney']; | |
foreach($array_payment as $output) { | |
$rate_bulat = round($result['rates']['IDR']); | |
$this->payment_model($output, $rate_bulat); | |
} | |
} | |
public function payment_model($payment, $rate) | |
{ | |
$data = array ('rate' => $rate); | |
$this->db->where('key', $payment); | |
$this->db->update('payments', $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment