Пример #1
0
 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;
         }
     }
 }