當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Orders::insert方法代碼示例

本文整理匯總了PHP中Orders::insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Orders::insert方法的具體用法?PHP Orders::insert怎麽用?PHP Orders::insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Orders的用法示例。


在下文中一共展示了Orders::insert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: finishAction

 public function finishAction()
 {
     $totalprice = $this->getRequest()->getParam('totalprice');
     session_start();
     $userid = $_SESSION['userid'];
     $orderdate = time();
     $this->orders_data = array('userid' => $userid, 'totalprice' => $totalprice, 'orderdate' => $orderdate);
     $order = new Orders();
     $this->orderid = $order->insert($this->orders_data);
     //取得mycart的資料
     $mycart = new Mycart();
     $where = "userid=" . $userid;
     $res = $mycart->fetchAll($where)->toArray();
     $i = 0;
     foreach ($res as $val) {
         $this->arr[$i++] = array('orderid' => $this->orderid, 'bookid' => $val['bookid'], 'nums' => $val['nums']);
     }
     $orderitem = new Orderitem();
     for ($i = 0; $i < count($this->arr); $i++) {
         $itemid = $orderitem->insert($this->arr[$i]);
     }
     if ($itemid > 0) {
         $mycart->delete($where);
         $this->view->info = "購買成功";
         $this->view->goto = "/finish/done?orderid=" . $this->orderid . "&totalprice=" . $totalprice;
         $this->_forward("ok", "globals");
     } else {
         $this->view->info = "購買失敗";
         $this->view->goto = "/cart/cart";
         $this->_forward("error", "globals");
     }
 }
開發者ID:yuxujian,項目名稱:YuNote,代碼行數:32,代碼來源:FinishController.php

示例2: Orders

<?php

require 'tables.php';
$products = json_decode($_POST['products']);
$order = new Orders();
$order->uid = $_POST['uid'];
$order->amount = $_POST['amount'];
$order->status = $_POST['state'];
$order->comment = $_POST['comment'];
$order->rid = $_POST['rid'];
$oid = $order->insert();
foreach ($products as $p) {
    $orderProducts = new orderProducts();
    $orderProducts->oid = $oid;
    $orderProducts->pid = $p->pid;
    $orderProducts->numofItems = $p->numofItems;
    $orderProducts->insert();
}
開發者ID:smagdy,項目名稱:PHPproject,代碼行數:18,代碼來源:addOrder.php

示例3: count

     $total = $total + $qt * $current_price;
 }
 $len = count($sku_ids);
 if ($len > 1) {
     $title = "合並| {$len} 筆訂單";
 }
 $newtotal = $total * $discount;
 $address = ReceiverAddress::getData($addressid);
 unset($address['id']);
 $address['module_id'] = 3;
 //---DB::Debug();
 DB::tranBegin('pay');
 //事務開始
 $address_id = ReceiverAddress::insert($address);
 $data = array('order_code' => $order_code, 'user_code' => $user_code, 'discount' => $discount, 'amount' => $newtotal, 'receiver_address_id' => $address_id, 'create_time' => time());
 $order_id = Orders::insert($data);
 foreach ($sku_ids as $sku_id => $qt) {
     $product_sku = ProductsSku::getData($sku_id, 'sku');
     $product_sku = isset($product_sku['sku']) ? $product_sku['sku'] : '';
     $stocknum = ProductsStock::getSkuStock($product_sku);
     if (!$product_sku || $stocknum < $qt) {
         DB::rollBack();
         Templates::Assign('errormsg', "訂單保存失敗,[{$product_sku}] 庫存不足,錯誤代碼 PY001");
         Templates::Display('error.html');
         exit;
     }
     $data = array('order_code' => $order_code, 'product_sku' => $product_sku, 'product_num' => $qt);
     OrdersProducts::insert($data);
     Cart::clearCart($userid, $sku_id);
     $locked = ProductsStockLock::add($order_code, $product_sku, $qt);
     if (!$locked) {
開發者ID:isonz,項目名稱:fxptpcn,代碼行數:31,代碼來源:pay.php


注:本文中的Orders::insert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。