【发布时间】:2017-09-07 19:51:12
【问题描述】:
我正在开发一个 PDO 功能,该功能允许您根据工具的序列号或文章 ID 执行搜索。但是,我希望能够在 id_art 和 num_serie 之间使用“-”同时搜索两者,例如在我的搜索栏 459999-1 中编写。
我尝试输入“-”但没有结果
public static function findAllByIdArt($id){
$id='%'.$id.'%';
$c=base::getConnection();
$query=$c->prepare("select * from outillage where (id_art like :num_serie) or (num_serie like :num_serie) or (num_serie and id_art like :num_serie '-' :id_art)");
$query->bindParam(':num_serie',$id,PDO::PARAM_INT);
$query->bindParam(':id_art',$id,PDO::PARAM_INT);
$dbres=$query->execute();
$d=$query->fetchAll();
$tab=array();
foreach ($d as $key => $value) {
$a=new Outillage();
$a->id=$value['id'];
$a->num_serie=$value['num_serie'];
$a->id_art=$value['id_art'];
$a->article=$value['article'];
$a->id_doc=$value['id_doc'];
$a->document=$value['document'];
$a->ilot=$value['ilot'];
$a->emplacement=$value['emplacement'];
$a->liste_tubes=$value['liste_tubes'];
$a->image=$value['image'];
$a->image2=$value['image2'];
$a->image3=$value['image3'];
$a->image4=$value['image4'];
$a->image5=$value['image5'];
$a->nb_utilisation=$value['nb_utilisation'];
$a->conforme=$value['conforme'];
$a->dateNonConfo=$value['dateNonConfo'];
$tab[]=$a;
}
return $tab;
}
【问题讨论】:
-
or (num_serie between :num_serie and :id_art or id_art between :num_serie and :id_art这是您要找的吗? -
ty 但没有。我想在我的搜索栏中搜索两列,例如:6999-01 6999= 我的数据库中的 id_art 和 01= num_serie。我已经可以搜索 num_serie 或 id_art 但不能同时使用“-”搜索(抱歉我的英语不好)