Php 搜索一个与我在codeigniter的文本框中给出的词不完全相同的词

Php 搜索一个与我在codeigniter的文本框中给出的词不完全相同的词,php,mysql,codeigniter,Php,Mysql,Codeigniter,我使用codeigniter中的模型从数据库中搜索一个单词。我做了精确的单词搜索。但当我给出部分词时,我也需要找到一个词。我用LIKE子句搜索一个单词。但我不知道如何在我的模型函数中使用LIKE%子句 型号: public function get_search() { $match = $this->input->post("search"); $match1 = $this->input->post("search1"); $match2 = $this-

我使用codeigniter中的模型从数据库中搜索一个单词。我做了精确的单词搜索。但当我给出部分词时,我也需要找到一个词。我用LIKE子句搜索一个单词。但我不知道如何在我的模型函数中使用LIKE%子句

型号:

public function get_search() {
  $match = $this->input->post("search");
  $match1 = $this->input->post("search1");
  $match2 = $this->input->post("search2");
  $match3 = $this->input->post("search3");
  $match4 = $this->input->post("search4");
  $match5 = $this->input->post("search5");
  $match6 = $this->input->post("search6");
  $this->db->query("SELECT * FROM patient_creation;");
  $this->db->where("patient_id like '$match' OR mobile like '$match1' OR name like '$match2' OR fathername like '$match3' OR address like '$match4' OR created BETWEEN '$match5' AND '$match6'");
  //$this->db->or_where("name LIKE '".$match2."%'"); 
  $query = $this->db->get("patient_creation");
  return $query->result();
}
我需要%搜索$match2、$match3和$match4变量。

更改:

$this->db->where("patient_id like '$match' OR mobile like '$match1' OR name like '$match2' OR fathername like '$match3' OR address like '$match4' OR created BETWEEN '$match5' AND '$match6'");

更改:

$this->db->where("patient_id like '$match' OR mobile like '$match1' OR name like '$match2' OR fathername like '$match3' OR address like '$match4' OR created BETWEEN '$match5' AND '$match6'");


注意
SELECT*FROM patient_creation中的分号准备查询字符串并在查询函数中使用

$query = "SELECT * FROM patient_creation where patient_id like '$match' OR mobile like '$match1' OR name like '$match2' OR fathername like '$match3' OR address like '$match4' OR created BETWEEN '$match5' AND '$match6'";

$this->db->query($query);

注意
SELECT*FROM patient_creation中的分号准备查询字符串并在查询函数中使用

$query = "SELECT * FROM patient_creation where patient_id like '$match' OR mobile like '$match1' OR name like '$match2' OR fathername like '$match3' OR address like '$match4' OR created BETWEEN '$match5' AND '$match6'";

$this->db->query($query);
公共函数get\u search(){
$match=$this->input->post(“搜索”);
$match1=$this->input->post(“search1”);
$match2=$this->input->post(“search2”);
$match3=$this->input->post(“search3”);
$match4=$this->input->post(“search4”);
$match5=$this->input->post(“search5”);
$match6=$this->input->post(“search6”);
$this->db->select(“*”);
$this->db->like(“患者id”,$match);
$this->db->或类似(“name”,$match2);
$this->db->or_like(“父名”、$match3);
$this->db->或类似(“地址”,$match4);
$this->db->或类似(“name”,$match2);
$this->db->where('created>=',$match5);
$this->db->where('created
public function get\u search(){
$match=$this->input->post(“搜索”);
$match1=$this->input->post(“search1”);
$match2=$this->input->post(“search2”);
$match3=$this->input->post(“search3”);
$match4=$this->input->post(“search4”);
$match5=$this->input->post(“search5”);
$match6=$this->input->post(“search6”);
$this->db->select(“*”);
$this->db->like(“患者id”,$match);
$this->db->或类似(“name”,$match2);
$this->db->or_like(“父名”、$match3);
$this->db->或类似(“地址”,$match4);
$this->db->或类似(“name”,$match2);
$this->db->where('created>=',$match5);

$this->db->where('created i try.It’s not work correct.因为它会影响其他变量。它也会显示所有不相关的单词。所以你的查询是错误的,对吗?我想它只是关于
的语法,比如
语法。我试过了。It’s not work correct.因为它会影响其他变量。它也会显示所有不相关的单词。所以你的查询是错误的,对吗?我想我这与
语法类似。这将仅将字符串“$match”或“$match1”或其他匹配到您的列。这将仅将字符串“$match”或“$match1”或其他匹配到您的列。