基本上我试图解析一个stdClass对象继承我使用的代码:
while($row = $data->fetch_assoc()){
try{
$products = $client->product_by_category_web_list($row['category_id'] , true, '', '2013-01-01', 0, 1500);
}catch(SoapFault $e){
echo "No Products under this Category";
}
$i = 0;
foreach($product as $products->item){
$cat_id = $row['category_id'];
$id = $product->$i->id;
$name = $product->$i->name;
$desc = $product->$i->descrShort;
$descLong = $product->$i->descrLong;
$avail = $product->$i->availableToSell;
$deliverable = $product->$i->deliverable;
$itemWeight = $product->$i->itemWeight;
$typelkp = $product->$i->typeLkp;
$stkbrandid = $product->$i->stkBrandId;
$dataVatId = $product->$i->dataVatId;
$query = "INSERT INTO `products` (`product_id` , `product_name` , `product_short_desc` , `product_long_desc` , `product_available , product_deliverable` , `product_item_weight` , `type_id` , `brand_id` , `vat_id`)
VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ?)";
$stmt = $mysql->prepare($query);
$stmt->bind_param("isssiiiiii" , $id , $name , $desc , $descLong , $avail , $deliverable , $itemWeight , $typelkp , $stkbrandid , $dataVatId);
$stmt->execute();
$mctp = "INSERT INTO `products_categories` (`product_id` , `category_id` , `row_updated`)
VALUES (? , ? , ?)";
$match = $mysql->query($mctp);
$match->bind_param("iii" , $id , $cat_id , 0);
$match->execute();
$i++;
}
}
Soap Call返回:
object(stdClass)#1 (1) {
["item"]=>
array(2) {
[0]=>
object(stdClass)#3 (10) {
["id"]=>
int(79493)
["name"]=>
string(34) "Claud Butler Phobos Kids Bike 2014"
["descrShort"]=>
string(0) ""
["descrLong"]=>
string(1269) "
This year we have worked harder than ever to offer you a great range of quality junior bikes. All exclusively designed and tested in the UK with todays young riders and the popularity of cycling foremost in our minds.
A great bike is the key to a positive riding experience, enjoyment and reliability can be the largest factors when considering your new bike and with over 130 years of design and manufacturing experience we have become the brand of family cycling. Bikes have very much become a fashion item and we believe the kids choices are as important as Mum and Dads so we have a vast range of eye catching models to choose from. We also offer alloy and steel framed models to suit all budgets while maintaining great quality and performance at great value.
Frame: HiTen Steel
Fork: Rigid Steel
Headset: Steel with bearings
Bars: Steel
Stem: Steel Quill Type
Chainset: Steel
Front Brake: Alloy V Rear
Brake: Alloy V
Rims: Alloy
Front Hub: Steel
Rear Hub: Steel
Tyres: 20 x 1.95 Front, 20 x 1.95 Rear
Seatpost: Steel
"
["availableToSell"]=>
bool(true)
["deliverable"]=>
bool(true)
["itemWeight"]=>
float(20)
["typeLkp"]=>
int(1)
["stkBrandId"]=>
int(136)
["dataVatId"]=>
int(1)
}
[1]=>
object(stdClass)#4 (10) {
["id"]=>
int(64223)
["name"]=>
string(45) "DiamondBack Accomplice Black 20 Inch BMX 2012"
["descrShort"]=>
string(0) ""
["descrLong"]=>
string(1514) "
DiamondBack Accomplice Black 20 Inch BMX 2012 Introduction
If there were laws to prevent us from providing you with pro-level quality in a complete at a suspiciously low price, the new Accomplice would have us doing some hard time. Fortunately for both of us; there aren't. The bike has, however spent some time on the drawing board over the last year. In addition to being cleaned up and simplified, the Accomplice also bolsters a new frame with Affix Bush BB, Affix 9T cassette rear hub, Affix tyres and Butted tapered forks and bars! Built in Germany by the world famous KHE bmx experts.
Specification and Features of DiamondBack Accomplice Black 20 Inch BMX 2012
Diamondback Ambigram CRMO 3 piece crank on Affix Mid Bush BB (red ano) with Affix Orbis Alloy 25T sprocket
Rear U brake with soft compound pad and front caliper brake with alloy hinge levers
Front KHE Big "V" rim on Affix Ting Hub, rear Alienation Black Sheep rim on Affix 9T Hub with Affix 2.1 Tyres
Affix system stem with 2 piece butted handlebar 8" rise 28.8" width
KHE Exhib Project 2 saddle/post combo
Diamondback/KHE collaboration: Full 4130 Butted chromoly BMX frame with integrated head tube and Diamond "X" Brace, with full 4130 butted tapered chromoly BMX forks"
DiamondBack Accomplice Black 20 Inch BMX 2012 is perfect for:
Hitting the parks, jumps or a bit of street riding.
"
["availableToSell"]=>
bool(true)
["deliverable"]=>
bool(true)
["itemWeight"]=>
float(15)
["typeLkp"]=>
int(1)
["stkBrandId"]=>
int(215)
["dataVatId"]=>
int(1)
}
}
}
每当我使用foreach循环时,我都会收到错误:无效的Arguement提供了foreach。我根据刚刚找到的答案解析它: Here