Created
July 18, 2014 13:52
-
-
Save fuzzysteve/79a704570ad4f8fb3bd2 to your computer and use it in GitHub Desktop.
costindex loader
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 | |
$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