$images = array(); foreach($dom->description->images->image as $image) { switch((string) $image[type']) { case thumbnail':$prodImgThumb = (string) $image; $prodImgAlias = (string) $image[alias']; if(!$prodImgAlias) $prodImgAlias = NULL; $stmt = db2_prepare($conn, "INSERT INTO sqlimages (Pid, Type, Alias, Location) VALUES (?, ?, ?, ?)"); db2_execute($stmt, array($prodID, thumbnail', $prodImgAlias, $prodImgThumb)); case full': $prodImgFull = (string) $image; $prodImgAlias = (string) $image[alias']; if(!$prodImgAlias) $prodImgAlias = NULL; $stmt = db2_prepare($conn, "INSERT INTO sqlimages (Pid, Type, Alias, Location) VALUES (?, ?, ?, ?)"); db2_execute($stmt, array($prodID, full', $prodImgAlias, $prodImgFull)); } } |
if(!$prodBrand) $prodBrand = " "; if(!$prodCategory) $prodCategory = " "; if(!$prodImgFull) $prodImgFull = " "; |
$stmt = db2_prepare($conn, "INSERT INTO sqlproduct (Pid, Name, Details, Brand, Category, Price, Weight, Size, Description) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); db2_execute($stmt, array($prodID, $prodName, $prodDetails, $prodBrand, $prodCategory, $prodPrice, $prodWeight, $prodSize, $fileContents)); |
CREATE VIEW Categories(Category) AS SELECT DISTINCT(XMLCAST( XMLQUERY(for $i in $t/product/description/category return $i' PASSING BY REF T.DESCRIPTION AS "t" RETURNING SEQUENCE) AS VARCHAR(128))) FROM xmlproduct AS t |
$stmt = db2_exec($conn, "SELECT * FROM Categories"); while(list($cat) = db2_fetch_array($stmt)) { echo "$cat "; } |
$stmt = db2_exec($conn, "SELECT DISTINCT(category) FROM SQLPRODUCT"); while(list($cat) = db2_fetch_array($stmt)) { echo "$cat ";} |
最新相关文章
发表评论