https://www.xunruicms.com/doc/1055.html
这个是搜索 证书+编号的代码
<?php namespace Phpcmf\Controllers;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class Zhengshu extends \Phpcmf\Home\Form
{
public function index() {
$this->_Home_List();
}
public function show() {
$this->_Home_Show();
}
public function post() {
$this->_Home_Post();
}
public function search() {
// 接收url传递的值
$title = dr_safe_replace(\Phpcmf\Service::L('input')->get('title'));
$zsbh = dr_safe_replace(\Phpcmf\Service::L('input')->get('zsbh'));
if (!$title) {
$this->_msg(0, '证书名称不能为空');
}
if (!$zsbh) {
$this->_msg(0, '证书编号不能为空');
}
// 查询
$row = \Phpcmf\Service::M()->table($this->init['table'])->where('title', $title)->where('zsbh', $zsbh)->getRow();
if (!$row) {
$this->_msg(0, '没有查询到');
}
// 查询到了调转到表单详情页面
$url = SITE_URL.'index.php?s=form&c='.$this->form['table'].'&m=show&id='.$row['id'];
dr_redirect($url);
}
}
如何改成输入证书或编号两项的其中一项就可以查询? 谢谢.
if (!$title and !$zsbh) { $this->_msg(0, '证书编号和title不能同时为空'); } // 查询 $row = \Phpcmf\Service::M()->table($this->init['table'])->where('title="'. $title.'" or zsbh="'. $zsbh.'"')->getRow(); if (!$row) { $this->_msg(0, '没有查询到'); }以上代码仅供参考,可能会有错误,具体你要实测一下。这个地方的证书怎么去掉呢?