模块表单中判断重复提交,如何实现 只查询 已审核通过 的内容

迅睿框架 更新 2022-10-25 16:48:30 远策

模块表单中判断提交title是否已经重复提交,这里是帮助文档的代码。

求助内容:如何实现 判断是否重复时,只去查询比对 已审核通过 的内容title。

<?php namespace Phpcmf\Controllers;

/**
 * 二次开发时可以修改本文件,不影响升级覆盖
 */

class Test extends \Phpcmf\Home\Mform
{

    public function index() {
        $this->_Home_List();
    }

    public function show() {
        $this->_Home_Show();
    }

    public function post() {
    
        if (IS_POST) {
            // 这里表示提交之前
            $post = \Phpcmf\Service::L('input')->post('data');
            $this->index = $this->_Module_Row($this->cid);
            if (\Phpcmf\Service::M()->table($this->init['table'])
            ->where('cid', $this->index['id'])
            ->where('title', $post['title'])->counts()) {
                $this->_json(0, 'title字段的值已经存在,不能重复提交');
            }
            
        }
    
        $this->_Home_Post();
    }
}


方案

  • 小波工作室 #1 · 2022-10-25 16:17:10
    满意答案
    if (\Phpcmf\Service::M()->table($this->init['table'])
                ->where('cid', $this->index['id'])
                ->where('status',1)
                ->where('title', $post['title'])->counts()) {
                    $this->_json(0, 'title字段的值已经存在,不能重复提交');
                }
  • 远策 #2 · 2022-10-25 16:48:10
    小波工作室 感谢感谢。小波设计的插件也强烈推荐!
  • 远策 #3 · 2022-10-25 16:48:30
    @小波工作室:感谢感谢。小波设计的插件也强烈推荐!

迅睿系统漏洞

GeoSeo工具箱
GeoSeo工具箱(2026-11-30)
新增内容创作工作台 优化CSS样式归集
分类信息
分类信息(2026-11-30)
分类信息把招聘、房产、二手、本地服务和商家收成同城门户。访客按开通城...
AI文章生成器
AI文章生成器(2026-11-30)
优化模型思考模式配置
小黄人工具箱
小黄人工具箱(2026-11-28)
新增模块列表栏目树功能
留言板
留言板(2026-11-28)
可用于在线留言,预约,反馈,询盘,后台可查看留言信息和审核
签到管理
签到管理(2026-11-27)
修复失效图标
站长工作台
站长工作台(2026-11-27)
1 新增 网站信息自定义字段支持删除功能 2 新增 网站信息--...