模塊表單中判斷提交title是否已經(jīng)重復(fù)提交,這里是幫助文檔的代碼。
求助內(nèi)容:如何實現(xiàn) 判斷是否重復(fù)時,只去查詢比對 已審核通過 的內(nèi)容title。
<?php namespace Phpcmf\Controllers;
/**
* 二次開發(fā)時可以修改本文件,不影響升級覆蓋
*/
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字段的值已經(jīng)存在,不能重復(fù)提交');
}
}
$this->_Home_Post();
}
}
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字段的值已經(jīng)存在,不能重復(fù)提交'); }回復(fù)@小波工作室 感謝感謝。小波設(shè)計的插件也強烈推薦!