Created
June 20, 2013 18:58
-
-
Save walterrenner/5825584 to your computer and use it in GitHub Desktop.
php oxid rest
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 | |
require_once dirname(__FILE__) . "/bootstrap.php"; | |
//Shop starten | |
$url_requestPRODUCT = 'http://student.mi.hs-offenburg.de:8080/sqlrest/PRODUCT'; | |
$responsePRODUCT = file_get_contents($url_requestPRODUCT); | |
$xmldatPRODUCT = simplexml_load_string($responsePRODUCT); | |
$url_requestCUSTOMER = 'http://student.mi.hs-offenburg.de:8080/sqlrest/CUSTOMER'; | |
$responseCUSTOMER = file_get_contents($url_requestCUSTOMER); | |
$xmldatCUSTOMER = simplexml_load_string($responseCUSTOMER); | |
$con=mysqli_connect("localhost","zzz","xxx","yyy"); | |
// Connection überprüfen | |
if (mysqli_connect_errno()) | |
{ | |
echo "Failed to connect to MySQL: " . mysqli_connect_error(); | |
} | |
foreach ($xmldatPRODUCT->PRODUCT as $entry) | |
{ | |
$tmp_urlPRODUCT = $url_requestPRODUCT."/".$entry; | |
$tmp_responsePRODUCT = file_get_contents($tmp_urlPRODUCT); | |
$xmldatPRODUCT = simplexml_load_string($tmp_responsePRODUCT); | |
// variablenname war hier falsch | |
// vorher: | |
// $ID = $tmp_xmldat->ID; | |
$ID = $xmldatPRODUCT->ID; | |
$NAME = $xmldatPRODUCT->NAME; | |
$PRICE = $xmldatPRODUCT->PRICE; | |
// die variable OXID ist der primary key der tabelle und muss gesetzt werden | |
// vorher: | |
// $resultPRODUCT = mysqli_query($con, "INSERT INTO oxarticles (OXARTNUM, OXTITLE, OXPRICE) VALUES ('$ID', '$NAME','$PRICE')"); | |
$resultPRODUCT = mysqli_query($con, "INSERT INTO oxarticles (OXID, OXARTNUM, OXTITLE, OXPRICE) VALUES ('$ID','$ID','$NAME','$PRICE')"); | |
} | |
mysqli_close($con); | |
Oxid::run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment