怎么增加其他字段搜索
这个是thinkphp后台
目前只有搜索标题title想增加其他字段上去
SearchAction.class.php
<form action="/?m=search" method="post">
<input type="hidden" name="modelid" value="9" id="modelid2">
<input type="text" class="chunk" name="keyword" placeholder="请输入您要查询的条件" />
<button type="submit" class="" value="" target="menuFrame" />点击查询</button>
</form>
<?php
class SearchAction extends PublicAction
{
public function index()
{
$keyword = $_GET['keyword'] = I('keyword');
$modelid = $_GET['modelid'] = I('modelid', 9, 'intval');
$this->assign(I('request.'));
//可搜索内容模型
$model_search = array();
foreach ($this->Model as $val) {
if ($val['issearch'] == 1) {
$model_search[] = $val;
}
}
$this->assign('model_search', $model_search);
$this->assign('seo_title', $this->Config['seo_title']);
$this->assign('seo_keywords', $this->Config['seo_keywords']);
$this->assign('seo_description', $this->Config['seo_description']);
$modelname = $this->Model[$modelid]['tablename'];
$where = array();
$where['status'] = 1;
$where['lang'] = LANG_ID;
$where['title'] = array('like',"%$keyword%");
$db = M($modelname);
$count = $db->where($where)->count();
if($count) {
import("@.ORG.Page");
$page = new Page($count, 1);
$pages = $page->show();
$field = 'id,url,title,keywords,description,thumb,createtime,tel';
$list = $db->field($field)->where($where)->order('listorder desc,id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
$this->assign('pages', $pages);
$this->assign('list', $list);
}
fangke_log('search','index',0,$keyword);
$this->assign(I('get.'));
$this->display();
}
}