我在下面给出了一个查询,除了一个过滤器外,其他查询都在工作
$sql='select * from zonez WHERE zoneprice between :minprice and :maxprice';
if(!empty($sizes)){
$sql .=' AND FIND_IN_SET(zonesize,:sizes)';
}
if(!empty($categories)){
$sql .=' AND FIND_IN_SET(webcategory,:categories)';
}
if(!empty($minimp)){
$sql .=' AND websrid IN (SELECT web from stats WHERE time > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 24 HOUR)) GROUP BY srid HAVING SUM(wh*30) between :minimp and :maximp)';
}
if(!empty($search)){
$sql .=' AND websrid IN (SELECT srid FROM websitez WHERE webtitle LIKE :search)';
}
if(!empty($type)){
$sql .=' AND FIND_IN_SET(zonetype,:type)';
}
$sql .=' group by misc1';
查询绑定代码
$stmt=$this->conn->prepare($sql);
$stmt->bindValue(":minprice",$minprice,PDO::PARAM_STR);
$stmt->bindValue(":maxprice",$maxprice,PDO::PARAM_STR);
if(!empty($sizes)){
$stmt->bindValue(":sizes",$sizes,PDO::PARAM_STR);
}
if(!empty($type)){
$stmt->bindValue(":type",$type,PDO::PARAM_STR);
}
if(!empty($categories)){
$stmt->bindValue(":categories",$categories,PDO::PARAM_STR);
}
if(!empty($search)){
$stmt->bindValue(":search","%$search%",PDO::PARAM_STR);
}
if(!empty($minimp)){
$stmt->bindValue(":maximp",$maximp,PDO::PARAM_STR);
$stmt->bindValue(":minimp",$minimp,PDO::PARAM_STR);
}
$stmt->execute();
$resultRow=$stmt->fetchAll(PDO::FETCH_ASSOC);
if($stmt->rowCount() > 0){
return $resultRow;
}else{
return false;
}
我从url得到$minprice和$maxprice,因为&prices=0-10,20-30,5-10
$prices=$_GET['prices'];
$gradeprice = str_replace('-', ',', $prices);
$gradepricee=rtrim($gradeprice,',');
$pricenumber = explode(',', $gradepricee);
$maxprice = max($pricenumber) ?: "5000";
$minprice = min($pricenumber) ?: "0";
此查询从url resutls/?page=1&categories=1,2&size=3,4&prices=0-10&imp=2000-1000000&type=1,2&search=blog&sort=1获取参数
除zoneprice筛选器外,此查询正在运行。此查询输出的结果与区域价格在:minprice和:maxprice之间无关。始终忽略区域价格在:minprice和:maxprice之间的条件。我在这个过滤器中尝试了所有可能的方法,但这不会影响这个查询。
暂无答案!
目前还没有任何答案,快来回答吧!