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

迅睿框架 更新 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
    @小波工作室:感谢感谢。小波设计的插件也强烈推荐!

迅睿系统漏洞

站群分站系统
站群分站系统(2026-10-15)
子站域名新增llms.txt访问
GEO系统
GEO系统(2026-10-14)
修复下载zip空白地址问题 修复流量复刻和任务队列错误
GeoSeo收录宝
GeoSeo收录宝(2026-10-14)
新增 站长工具箱 前端首页自动调用meta 数据
滑块验证码 Gocaptcha
滑块验证码 Gocaptcha(2026-10-13)
基于开源项目 go-captcha 的行为验证码插件,滑动拼图、区域...
GeoSeo工具箱
GeoSeo工具箱(2026-10-13)
优化巡检任务
GeoSeo排名助手
GeoSeo排名助手(2026-10-11)
加入大模型自定义
SEO聚合关键字
SEO聚合关键字(2026-10-11)
优化关键字列表页最多支持1万篇文章,过多会导致服务器扛不住;
CMS内容同步复制
CMS内容同步复制(2026-10-10)
增加时间是否更新的开关