Guest User

Untitled

a guest
Jan 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1.     public function importRisks() {
  2.         $fp = fopen('/home/jborzilleri/Downloads/ETF_Risk_Information_SPDRS-SPDR U-Mobile_Sep 15 2011.csv', 'r');
  3.  
  4.         $funds = array();
  5.         while( false !== ($line = fgetcsv($fp)) ) {
  6.             if( count($line) < 4 ) {
  7.                 printf("Not enough data for ticker: %s<br>", @$line[1]);
  8.                 continue;
  9.             }
  10.             $ticker = $line[1];
  11.             $fund = Query::build()
  12.                 ->attribute('Products.Product Ticker', $ticker, QUERY_TERM)
  13.                 ->run('Fund');
  14.  
  15.             if( count($fund) == 0 ) {
  16.                 printf("cannot find: %s<br>", $ticker);
  17.                 continue;
  18.             }
  19.             $fund = $fund[0];
  20.  
  21.             $fund->setAttribute('Products.mobileRisk', $line[3]);
  22.             $fund->save();
  23.             printf("updating: %s<br>", $ticker);
  24.         }
  25.     }
Add Comment
Please, Sign In to add comment