http://apdwn.com/doc/1055.html
這個是搜索 證書+編號的代碼
<?php namespace Phpcmf\Controllers;
/**
* 二次開發(fā)時可以修改本文件,不影響升級覆蓋
*/
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, '沒有查詢到');
}
// 查詢到了調(diào)轉(zhuǎn)到表單詳情頁面
$url = SITE_URL.'index.php?s=form&c='.$this->form['table'].'&m=show&id='.$row['id'];
dr_redirect($url);
}
}
如何改成輸入證書或編號兩項的其中一項就可以查詢? 謝謝.
這個很好實現(xiàn)啊,代碼都大部分代碼都寫好了,只需要你分期代碼,你看代碼上面寫的是兩個字段條件都匹配,它是and的關(guān)系,你只需要改成or的關(guān)系,就是或者的關(guān)系,把程序代碼改成或者兩個,二選一都可以,這種條件意思就是讓你重新組合一個條件。
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, '沒有查詢到'); }以上代碼僅供參考,可能會有錯誤,具體你要實測一下。
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
這個地方的證書怎么去掉呢?
非常感謝,可以了.