function act_sureAddAttr() { $bool = array(); $data = array(); $id = trim($_POST['attrId']); $data['attributesName'] = post_check(trim($_POST['attributesName'])); if (empty($id)) { $bool = OrderAttrModel::getOrderAttrList("*", "where attributesName='{$data['attributesName']}'"); if ($bool) { return 2; } $insertid = OrderAttrModel::insertRow($data); if ($insertid) { return 1; } else { return false; } } else { $bool = OrderAttrModel::getOrderAttrList("*", "where id!={$id} and attributesName='{$data['attributesName']}'"); if ($bool) { return 2; } $updatedata = OrderAttrModel::update($data, "and id='{$id}'"); if ($updatedata) { return 1; } else { return false; } } }
/** * 插入一条记录 * @para $data as array * return insert_id */ public static function insertRow($data) { self::initDB(); $sql = array2sql($data); $sql = "INSERT INTO `" . self::$table . "` SET " . $sql; $query = self::$dbConn->query($sql); if ($query) { $insertId = self::$dbConn->insert_id(); return $insertId; } else { self::$errCode = "003"; self::$errMsg = "error"; return false; } }
public function view_editOrderAttr() { $id = intval($_GET['id']); $orderAttr = OrderAttrModel::getOrderAttrList("*", "where id={$id}"); $this->smarty->assign('orderAttr', $orderAttr); $navlist = array(array('url' => '', 'title' => '系统设置'), array('url' => 'index.php?mod=orderSetting&act=property', 'title' => '订单属性'), array('url' => '', 'title' => '修改订单属性')); $this->smarty->assign('navlist', $navlist); $this->smarty->assign('toptitle', '修改订单属性'); $toplevel = 3; //一级菜单的序号 $this->smarty->assign('toplevel', $toplevel); $secondlevel = 36; //当前的二级菜单 $this->smarty->assign('secondlevel', $secondlevel); $this->smarty->assign('curusername', $_SESSION['userName']); $this->smarty->display('ordreAttrAdd.htm'); }