gpt4 book ai didi

php - 如何使用codeigniter事件记录在mysql表的单个字段中搜索多个值?

转载 作者:行者123 更新时间:2023-11-30 01:03:52 24 4
gpt4 key购买 nike

我必须在 codeigniter 中使用 mysql 搜索字段中的多个值。这是我的代码。

在 Controller 中

public function vpsearch()
{
$data['info'] = $this->psearch_m->emp_search_form();

$this->load->view("employer/result",$data);

}

IN 模型

public function emp_search_form()
{
$skill = $this->security->xss_clean($this->input->post('ps_skills'));
$jrole = $this->input->post('ps_jobrole'));


if ( $jrole !== NULL)
{
return $this->db->get('js_edu_details');
$this->db->like('js_skills','$skill');
}
}

查看,即 (../employer/result)

foreach($info->result() as $row)
{
echo $row->js_id."<br/><br/>" ;
}

但是,我获取的是“js_edu_details”表中的所有记录,而不是搜索“技能”的字段。

我哪里出错了?如有任何帮助,我们将不胜感激,提前致谢。

最佳答案

尝试:

public function emp_search_form()
{
$skill = $this->security->xss_clean($this->input->post('ps_skills'));
//$skill = $this->input->post('ps_skills', true); other short way of getting the above result with `xss clean`
if ( $jrole !== NULL)
{
$this->db->like('js_skills',$skill); #remove the single quote around the `$skill`
$res = $this->db->get('js_edu_details');
echo $this->db->last_query(); #try to print the query generated
return $res;
}
}

Return 语句应该位于 like 语句之后

关于php - 如何使用codeigniter事件记录在mysql表的单个字段中搜索多个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19853225/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com