Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 搜索查询在Laravel中运行不正常_Php_Mysql_Laravel - Fatal编程技术网

Php 搜索查询在Laravel中运行不正常

Php 搜索查询在Laravel中运行不正常,php,mysql,laravel,Php,Mysql,Laravel,这是我的搜索查询,如果我在搜索字段中输入“john”或“peter”,则效果良好。如果我输入全名“约翰·彼得”,它对我不起作用。 在我的数据库中有两个字段“firstname”“lastname” 我认为,您需要重构代码才能正常工作 public static function searchSubmissions($request, $candidateIds = array(),$isscontact = NULL){ $querys = DB::table('submission

这是我的搜索查询,如果我在搜索字段中输入“john”或“peter”,则效果良好。如果我输入全名“约翰·彼得”,它对我不起作用。 在我的数据库中有两个字段“firstname”“lastname”


我认为,您需要重构代码才能正常工作

public static function searchSubmissions($request, $candidateIds = array(),$isscontact = NULL){
      $querys = DB::table('submissions')->select('submissions.*');
  if ( Input::has('candidatename') and $request->input('candidatename') != NULL){
      $querys->join('candidates','candidates.candidateid','=','submissions.candidateid');
      $querys->where('candidates.firstname', 'LIKE', '%'. $request->input('candidatename').'%')->orWhere('candidates.lastname', 'LIKE', '%'. $request->input('candidatename') .'%')->where('submissions.status','1');
  }
   $result = $querys->paginate(PAGELIMIT);

  return $result ;
}

看看这个

我认为,您需要重构代码才能正常工作

public static function searchSubmissions($request, $candidateIds = array(),$isscontact = NULL){
      $querys = DB::table('submissions')->select('submissions.*');
  if ( Input::has('candidatename') and $request->input('candidatename') != NULL){
      $querys->join('candidates','candidates.candidateid','=','submissions.candidateid');
      $querys->where('candidates.firstname', 'LIKE', '%'. $request->input('candidatename').'%')->orWhere('candidates.lastname', 'LIKE', '%'. $request->input('candidatename') .'%')->where('submissions.status','1');
  }
   $result = $querys->paginate(PAGELIMIT);

  return $result ;
}

看看这个

,因为这里没有
john peter
。你应该了解
LIKE
子句在MySQL中是如何工作的()有没有可能??因为我的名字叫约翰。在我的查询中,我还使用了'LIKE','%'。仅仅因为没有
john peter
。您应该了解
LIKE
子句在MySQL中是如何工作的()有没有可能??因为我的名字叫约翰。在我的查询中,我还使用了'LIKE'、'%'。非常感谢。现在它的功能正常了。今天你教了我一堂很棒的课,你也应该从Shyamakwana那里知道。我的评论。是的,当然,兄弟,谢谢你,伙计。现在它的功能正常了。今天你教了我一堂很棒的课,你也应该从Shyamakwana那里知道。我的评论。是的,当然,兄弟_/_