扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
$stmt = db2_prepare($conn, "SELECT XMLSERIALIZE(XMLQUERY($xquery' PASSING BY REF T.PORDER AS \"t\" RETURNING SEQUENCE) AS CLOB(32K)) FROM xmlporder AS t WHERE POid = ?"); db2_execute($stmt, array($id)); list($po) = db2_fetch_array($stmt); echo $po; |
$stmt = db2_prepare($conn, "SELECT POrder FROM sqlporder WHERE POid = ?"); db2_execute($stmt, array($id)); $sum = 0.0; while(list($po) = db2_fetch_array($stmt)) { |
$dom = simplexml_load_string($po); foreach($dom->items->item as $item) { $cpid = (string) $item[pid']; $price = (float) $item[price']; |
$sum += $price * (integer) $item[quantity']; |
$stmt2 = db2_prepare($conn, "SELECT Name FROM sqlproduct WHERE Pid = ?"); db2_execute($stmt2, array($cpid)); if($stmt2) { list($prodName) = db2_fetch_array($stmt2); ?> | ||
$ |
代码的关系版本向应用程序引入了较多的逻辑。
报告客户的订购历史记录
客户可以单击索引中的 Order history 链接,列出他们的所有采购订单:
图 10. 订购历史记录
DB2 Viper
$xquery = for $po in $t/purchaseOrder let $items := for $item in $po/items/item |
let $name := for $i in db2-fn:xmlcolumn("XMLPRODUCT.DESCRIPTION")/product where $i/@pid = $item/@pid return $i/description/name/text() return {xs:string($item/@quantity)} x @ ${xs:string($item/@price)} {$name} return Order #{xs:string($po/@id)} placed on {xs:string($po/@orderDate)}{$items} ; $stmt = db2_prepare($conn, "SELECT XMLSERIALIZE(XMLQUERY ($xquery' PASSING BY REF T.PORDER AS \"t\" RETURNING SEQUENCE) AS CLOB(32K)) FROM xmlporder AS t ORDER BY POid DESC"); db2_execute($stmt); while(list($po) = db2_fetch_array($stmt)) { echo $po; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者