Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Informationen und Variablen
- $keyID = "xxxxx";
- $vCode = "xxxx";
- $server = "localhost";
- $username = "root";
- $password = "";
- $conn = new mysqli($server, $username, $password, "asset");
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $xml = file_get_contents("https://api.eveonline.com/corp/StarbaseList.xml.aspx?keyID=" . $keyID . "&vCode=" . $vCode);
- // echo "<pre>".htmlspecialchars($xml)."</pre>";
- //xml zerlegen
- $xml = simplexml_load_string($xml);
- // schleife durchlaufen
- //sql Tabelle eintragen der Daten
- foreach ($xml->result->rowset->row as $row) {
- // prepare statments hier werden anweisung reingeschrieben
- $stmt = $conn->prepare("INSERT INTO starbases (itemID, typeID, locationID, moonID, state, stateTimestamp, onlineTimestamp, standingOwnerID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
- // a itemID -> bedeutet Objekte Klasse ist xml Objekt (simple_xml) Zuweisung des Schlüsels mit einem Wert (itemID : atribut 233233)
- $a = $row->attributes();
- // timestampszeilen hier explizit in eine String Wandeln
- $t1 = (string)$a["stateTimestamp"];
- $t2 = (string)$a["onlineTimestamp"];
- //Eintragen der Werte der einzelnen Schluessel in die tabelle, Achtung vorgabe der typen "iiiiissi" (int int int int int str str int)
- $stmt->bind_param("iiiiissi", $a["itemID"], $a["typeID"], $a["locationID"], $a["moonID"], $a["state"], $t1, $t2, $a["standingOwnerID"]);
- $stmt->execute();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement