本文整理汇总了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");
}
}
示例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();
}
示例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) {