Exemplo n.º 1
0
        if ($level == 3) {
            $topParentId = $_POST['top_parent_id'] = $tougao_categoryData['parent_id'];
        } elseif ($level == 2) {
            $topParentId = $_POST['top_parent_id'] = $tougao_categoryData['id'];
        } else {
            $topParentId = $_POST['top_parent_id'] = 0;
        }
        $_POST['level'] = $level;
    }
    if ($name == "" || $alias == "") {
        $createMessage = "请把分类信息填写完整!!";
    } else {
        $sql = 'SELECT * FROM `tougao_category` WHERE name="' . $name . '" or alias ="' . $alias . '"';
        $rs = $pdo->query($sql);
        $row = $rs->fetchAll();
        //取得所有记录
        $count = count($row);
        if ($count == 0) {
            // var_dump($_POST);
            $lastetId = TouGao_categoryModel::model()->create($_POST);
            if ($lastetId != FALSE) {
                $createMessage = "添加成功";
            } else {
                echo $sql;
                $createMessage = "添加失败";
            }
        } else {
            $createMessage = '分类名称重复 或者 别名重复!';
        }
    }
}
Exemplo n.º 2
0
    $thumb = $row['thumb'];
    $banner = $row['banner'];
}
if ($dopost == 'update') {
    $id = $_POST['cid'];
    $name = $_POST['name'];
    $alias = $_POST['alias'];
    $tag = $_POST['tag'];
    $thumb = $_POST['thumb'];
    $banner = $_POST['banner'];
    if ($alias == "" || $name == "") {
        $updateMessage = "请把信息填写完整!!";
    } else {
        $sql = 'SELECT * FROM `tougao_category` WHERE (`name`="' . $name . '" OR `alias`="' . $alias . '") AND `id`<>"' . $id . '"';
        $rs = $pdo->query($sql);
        $row = $rs->fetchAll();
        //取得所有记录
        if (count($row) == 0) {
            $row = array('name' => $name, 'alias' => $alias, 'tag' => $tag, 'thumb' => $thumb, 'banner' => $banner);
            $result = TouGao_categoryModel::model()->update(array('id' => $id), $row);
            if ($result > 0) {
                $updateMessage = "修改成功";
            } else {
                echo $sql;
                $updateMessage = "修改失败";
            }
        } else {
            $updateMessage = '标题或者别名重复!';
        }
    }
}