$rate = $columns[0]->plaintext; $buy = $columns[3]->plaintext; $sell = $columns[2]->plaintext; if ($this->db->get_count($this->_table_rate, array('bank' => $bank_name, 'name' => $rate, 'last_update' => $last_update)) == 0) { $data = array('bank' => $bank_name, 'last_update' => $last_update, 'name' => $rate, 'sell' => $sell, 'buy' => $buy); $this->db->insert($this->_table_rate, $data); echo 'Insert ' . $rate . ' for ' . $bank_name . ' ' . $last_update . PHP_EOL; } $i++; } //update last update $bank_last_update = array('last_update' => $last_update); echo 'Update bank ' . $bank_name . ' last update for ' . $last_update . PHP_EOL; if ($this->db->get_count($this->_table_bank, array('bank' => $bank_name))) { $this->db->update($this->_table_bank, $bank_last_update, array('bank' => $bank_name)); } else { $bank_last_update['bank'] = $bank_name; $this->db->insert($this->_table_bank, $bank_last_update); } } } echo 'Calling script...' . PHP_EOL; $run = new Rates(); $run->get_bca_rates(); $run->get_mandiri_rates(); $run->get_bni_rates(); $run->get_bri_rates(); /* * filename : rates.php * location: /rates.php */