当前位置: 首页>>代码示例>>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;未经允许,请勿转载。