求助 版主:官方研发技术组
模块表单中判断重复提交,如何实现 只查询 已审核通过 的内容
类型:迅睿CMS 更新时间: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
    Chrome 0
    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
    Chrome 0
    小波工作室 感谢感谢。小波设计的插件也强烈推荐!
  • 远策
    #3楼    远策
    2022-10-25 16:48:30
    Chrome 0
    @小波工作室:感谢感谢。小波设计的插件也强烈推荐!