Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2. // Informationen und Variablen
  3. $keyID = "xxxxx";
  4. $vCode = "xxxx";
  5.  
  6. $server = "localhost";
  7. $username = "root";
  8. $password = "";
  9.  
  10. $conn = new mysqli($server, $username, $password, "asset");
  11.  
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15.  
  16. $xml = file_get_contents("https://api.eveonline.com/corp/StarbaseList.xml.aspx?keyID=" . $keyID . "&vCode=" . $vCode);
  17.  
  18. // echo "<pre>".htmlspecialchars($xml)."</pre>";
  19.  
  20. //xml zerlegen
  21.  
  22. $xml = simplexml_load_string($xml);
  23. // schleife durchlaufen
  24.  
  25. //sql Tabelle eintragen der Daten
  26.  
  27. foreach ($xml->result->rowset->row as $row) {
  28. // prepare statments hier werden anweisung reingeschrieben
  29. $stmt = $conn->prepare("INSERT INTO starbases (itemID, typeID, locationID, moonID, state, stateTimestamp, onlineTimestamp, standingOwnerID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
  30. // a itemID -> bedeutet Objekte Klasse ist xml Objekt (simple_xml) Zuweisung des Schlüsels mit einem Wert (itemID : atribut 233233)
  31. $a = $row->attributes();
  32. // timestampszeilen hier explizit in eine String Wandeln
  33. $t1 = (string)$a["stateTimestamp"];
  34. $t2 = (string)$a["onlineTimestamp"];
  35. //Eintragen der Werte der einzelnen Schluessel in die tabelle, Achtung vorgabe der typen "iiiiissi" (int int int int int str str int)
  36. $stmt->bind_param("iiiiissi", $a["itemID"], $a["typeID"], $a["locationID"], $a["moonID"], $a["state"], $t1, $t2, $a["standingOwnerID"]);
  37. $stmt->execute();
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement