thinkphp用like搜索简单demo

搜索函数

public function SearchList()
    {

        $condition = I('searchVal');
        $ArticleDb = M("article");
        $searchVal['title|content']= array('like',"%".$condition."%");
        $count = $ArticleDb->where($searchVal)->count();
        $list = $ArticleDb->where($searchVal)->select();

        $this->assign('list',$list);

        $this->display();


    }
前台调用
<div class="file_holder">
    <ul>
        <volist name="list" id="vo">
            <li>
                <a href="{:U('ArticleList/ArticleArticle?aid='.$vo['aid'])}" >
                    {$vo.title}
                </a>
            </li>
        </volist>
    </ul>

</div>

随机浏览