Skip to content

Instantly share code, notes, and snippets.

@fuzzysteve
Created July 18, 2014 13:52
Show Gist options
  • Save fuzzysteve/79a704570ad4f8fb3bd2 to your computer and use it in GitHub Desktop.
Save fuzzysteve/79a704570ad4f8fb3bd2 to your computer and use it in GitHub Desktop.
costindex loader
<?php
$ch = curl_init();
$url="http://public-crest-sisi.testeveonline.com/industry/systems/";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
if ($result===false) {
error_log(curl_error($ch));
}
curl_close($ch);
$response=json_decode($result);
include ("db.inc.php");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$sql='insert into costIndex(solarSystemID,activityID,costIndex) values (:ssid,:aid,:ci)';
$stmt = $dbh->prepare($sql);
$dbh->beginTransaction();
foreach ($response->items as $system) {
$solarSystemID=$system->solarSystem->id;
echo $solarSystemID."\n";
foreach ($system->systemCostIndices as $index) {
$stmt->execute(array(':ssid'=>$solarSystemID,':aid'=>$index->activityID,':ci'=>$index->costIndex));
}
}
$dbh->commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment