本文整理匯總了PHP中Tab::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tab::model方法的具體用法?PHP Tab::model怎麽用?PHP Tab::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tab
的用法示例。
在下文中一共展示了Tab::model方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionEdit
public function actionEdit()
{
if (empty($_POST)) {
$info = Zine::model()->findByPk($_REQUEST['id']);
$viewData = array();
$viewData['info'] = $info;
$this->render('edit', $viewData);
exit;
}
$res = array('statusCode' => 200, 'message' => '修改成功!');
try {
$m = Tab::model()->findByPk($_REQUEST['id']);
if (empty($m)) {
throw new Exception('該譜子不存在');
}
$m->name = $_REQUEST['name'];
//譜子名稱
$m->class = $_REQUEST['class'];
//歌曲名稱
$m->scover = $_REQUEST['scover'];
//專輯id
$m->mcover = $_REQUEST['mcover'];
$m->bcover = $_REQUEST['bcover'];
$m->content = $_REQUEST['content'];
$m->poptab = $_REQUEST['poptab'];
$m->solotab = $_REQUEST['solotab'];
$m->views = $_REQUEST['views'];
//自建分類
$m->downs = $_REQUEST['downs'];
$m->replys = $_REQUEST['replys'];
$m->date = $_REQUEST['date'];
$m->editor = $_REQUEST['editor'];
$m->intro = $_REQUEST['intro'];
$m->link1 = $_REQUEST['link1'];
$m->link2 = $_REQUEST['link2'];
$m->link3 = $_REQUEST['link3'];
$m->link4 = $_REQUEST['link4'];
$m->veditor = $_REQUEST['veditor'];
$m->peditor = $_REQUEST['peditor'];
$m->team = $_REQUEST['team'];
$m->taobaolink = $_REQUEST['taobaolink'];
$m->bbslink = $_REQUEST['bbslink'];
$m->qita = $_REQUEST['qita'];
$m->market_price = $_REQUEST['market_price'];
$m->cost_price = $_REQUEST['cost_price'];
$m->sell_price = $_REQUEST['sell_price'];
$m->quantity = $_REQUEST['quantity'];
$m->virtual_price = $_REQUEST['virtual_price'];
$flag = $m->save();
if (!$flag) {
throw new exception('修改失敗');
}
} catch (Exception $e) {
$res['statusCode'] = 300;
$res['message'] = '失敗【' . $e->getMessage() . '】';
}
$res['navTabId'] = 'zineList';
$res['callbackType'] = 'closeCurrent';
$res['forwardUrl'] = '/manage/zine/index';
$this->ajaxDwzReturn($res);
}
示例2: dealWithCancelOrderProductStock
/**
* 處理取消訂單的庫存
* @param $orderId
*/
public function dealWithCancelOrderProductStock($orderId)
{
if (!$orderId) {
throw new exception('訂單的id不能為空!');
}
$list = OrderProduct::model()->findAllByAttributes(array('order_id' => $orderId));
if (empty($list)) {
throw new exception('訂單商品為空!');
}
foreach ($list as $row) {
if ($row['type'] == 1) {
$pInfo = Tab::model()->findByPk($row['product_id']);
} elseif ($row['type'] == 2) {
$pInfo = Zine::model()->findByPk($row['product_id']);
} else {
$pInfo = Product::model()->findByPk($row['product_id']);
}
if (empty($pInfo)) {
throw new exception('商品【' . $row['product_name'] . '】不存在!');
}
$pInfo->quantity += $row['quantity'];
$flag = $pInfo->save();
if (empty($flag)) {
throw new exception('商品【' . $row['product_name'] . '】庫存恢複失敗!');
}
if (!$row['type']) {
$stockInfo = ProductStock::model()->findByAttributes(array('product_id' => $row['product_id'], 'attr_id' => $row['size_id']));
if (empty($stockInfo)) {
throw new exception('商品【' . $row['product_name'] . '】庫存不存在!');
}
$stockInfo->quantity += $row['quantity'];
$flag = $stockInfo->save();
if (empty($flag)) {
throw new exception('訂單【' . $row['product_name'] . '】庫存恢複失敗!');
}
}
}
return true;
}
示例3: saveOrderProduct
/**
* 保存訂單商品信息
* @param $oid
* @param $cartinfo
* @return bool
* @throws Exception
*/
protected function saveOrderProduct($userId, $order_id, $cartInfo)
{
$list = $cartInfo['list'];
foreach ($list as $row) {
if ($row['type'] == 1) {
$pInfo = Tab::model()->findByPk($row['product_id']);
if (empty($pInfo)) {
throw new Exception("譜子不存在!", 500);
}
} elseif ($row['type'] == 2) {
$pInfo = Zine::model()->findByPk($row['product_id']);
if (empty($pInfo)) {
throw new Exception("雜誌商品不存在!", 500);
}
} else {
$pInfo = Product::model()->findByPk($row['product_id']);
if (empty($pInfo)) {
throw new Exception("訂單商品不存在!", 500);
}
}
if ($row['sell_price'] != $pInfo['sell_price']) {
throw new exception('價格錯誤,請重試');
}
$m = new OrderProduct();
$m->order_id = $order_id;
$m->user_id = $userId;
$m->product_id = $row['product_id'];
$m->type = $row['type'];
$m->product_sn = empty($row['type']) ? $pInfo['product_sn'] : '';
$m->product_name = empty($row['type']) ? $pInfo['product_name'] : ($row['type'] == 1 ? $pInfo['tabname'] : $pInfo['name']);
$m->size_id = $row['size_id'];
$m->brand_id = $row['type'] == 0 ? $pInfo['brand_id'] : 0;
$m->sell_price = $row['sell_price'];
$m->quantity = $row['quantity'];
//$m->shipping_id = 0;
//$m->shipping_code = '';
//$m->shipping_time = 0;
$opid = $m->save();
if (empty($opid)) {
throw new Exception("訂單商品生成失敗!", 1);
}
$this->updateProductStock($pInfo, $row);
//更新商品的庫存
}
return true;
}
示例4: actionChange
public function actionChange()
{
$res = array('statusCode' => 200, 'message' => '修改成功!');
$info = Tab::model()->findByPk($_REQUEST['id']);
try {
if (empty($info)) {
throw new exception('記錄不存在了!');
}
$info->is_show = $_REQUEST['is_show'];
$flag = $info->save();
if (empty($flag)) {
throw new exception('修改狀態失敗!');
}
} catch (Exception $e) {
$res['statusCode'] = 300;
$res['message'] = '刪除失敗【' . $e->getMessage() . '】';
}
$res['callbackType'] = 'reloadTab';
$res['forwardUrl'] = '/manage/tab/index';
$this->ajaxDwzReturn($res);
}