<?php
namespace Home\Controller;
use Think\Controller;
class SearchController extends CommonController {
	public function index(){
		if ($q = I('q')) {
			$_where = array(
				'title|description|keywords' => array('like','%'.$q.'%'),
				'status' => array('eq',1),
				);
			$m = M('Content');
			$count = $m -> where($_where) -> count();
			$Page = new \Common\Vendor\Page($count,20);
			$this -> lists = $m -> where($_where) -> limit($Page->firstRow.','.$Page->listRows) -> order('id desc') -> select();
			if ($count > 20) {
				$this -> pages = $Page->show();
			}
			$this -> type = $type;
			$this->display();
		}else{
			$this -> error('请输入要搜索的文字');
		}
	}
}