Skip to content

Instantly share code, notes, and snippets.

@walterrenner
Created June 20, 2013 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterrenner/5825584 to your computer and use it in GitHub Desktop.
Save walterrenner/5825584 to your computer and use it in GitHub Desktop.
php oxid rest
<?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