think php 多条件检索+自带分页

//视图
<form action="/homework/homework/index" method="get"> <input type="text" name="name" placeholder="请根据姓名进行搜索"> <input type="text" name="price" placeholder="请根据价格进行搜索"> <input type="submit" value="立即搜索"> </form>
//控制器
    public function index()
    {
        //接受搜索关键字
        $name = input(name);
         $price=input(price);
        $data = HomeworkModel::listInfo($name,$price);
        $this->assign(data, $data);
        return view();
    }

think  php  多条件检索+自带分页

 

 

//模型
   public static function listInfo($name,$price)
    {

        $model = new self();
        if (isset($name)) {
            $model = $model->where(name, like, "%$name%");
        }
        if (isset($price)){
            $model = $model->where(price, like, "%$price%");
        }

           $data= $model->paginate(2);
            return $data;

    }

 

think php 多条件检索+自带分页

上一篇:iOS中委托使用小结


下一篇:PHP中的IMAP扩展简单入门