3 * Table Definition for core_curr_rate
5 require_once 'DB/DataObject.php';
7 class Pman_Core_DataObjects_Core_curr_rate extends DB_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'core_curr_rate'; // table name
19 /* the code above is auto generated do not remove the tag below */
22 function applyFilters($q, $au, $roo)
28 * current rate fetching
30 * - we used to do historical rates... (but sources keep disappearing for that..)
32 * this just get's the current rates from the ecb..
41 // how often do we need to know this..?
42 // let's assume we do it once a week..
43 $x = DB_DataObject::Factory('core_curr_rate');
44 $x->whereAdd('to_date > NOW()');
46 // got some data for beyond today..
50 // load our default rates to start with..
51 $dom = simplexml_load_file(dirname(__FILE__).'/../eurofxref-daily.xml');
53 $rates['TWD'] = 46.7008412;
54 $rates['VND'] = 26405.3;
57 foreach($dom->Cube->Cube->Cube as $c) {
58 //echo '<PRE>';print_r($c );
59 $rates[(string)$c['currency']] = (string)$c['rate'];
61 $rates['RMB'] = $rates['CNY'] ;
65 // now try loading from latest..
68 $f = @file_get_contents('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml');
73 $dom = simplexml_load_file($target);
75 $rates['TWD'] = 46.7008412;
76 $rates['VND'] = 26405.3;
78 foreach($dom->Cube->Cube->Cube as $c) {
79 //echo '<PRE>';print_r($c );
80 $rates[(string)$c['currency']] = (string)$c['rate'];
82 $rates['RMB'] = $rates['CNY'] ;