public function search() {
$this->Paginator->settings = $this->paginate;
$this->loadmodel('Usermgmt.User');
if ($this->request -> isGet()) {
$this->User->set($this->data);
$keyword=$this->data['Doctors']['search'];
$cond=array('OR'=>array("User.username LIKE '%$keyword%'","User.email LIKE '%$keyword%'", "User.first_name LIKE '%$keyword%'", "User.last_name LIKE '%$keyword%'", "User.positions LIKE '%$keyword%'"));
$result = $this->paginate('User',array($cond));
$this->set('result',$result);
}
这里是cakephp版本cakephp-2.4.5中搜索功能的代码,当我给出搜索if ($this->request -> isGet()) {
的请求时执行并且$keyword
值变空。这里我怎么能得到 GET参数这里
答案 0 :(得分:2)
删除此编码
$this->User->set($this->data);
$keyword=$this->data['Doctors']['search'];
如果您正在使用get方法
,请添加此项$keyword = $this->params['url']['keyvalue'];
此处keyvalue是用户参数名称
答案 1 :(得分:2)
Thulasi的方法可行,但请注意,不推荐使用$this->params['url']
,而是$this->request->query
。所以新建议的方法是:
$keyword = $this->request->query['keyword'];
另请参阅此主题的the documentation。