此功能旨在从两个单独的表医生和诊所返回医生的信息
function searchSubs($spc, $stt, $name, $ls, $ll){
$query ='
SELECT doctor.*, clinic.address
FROM doctor
LEFT JOIN clinic
ON ( doctor.id = clinic.dr <<STATE CONDITION>>)
WHERE doctor.dr_name REGEXP :dr <<SPECIALIZATION CONDITION>>
AND doctor.active = 1
LIMIT :s, :l;
'
;
$query = ($spc == 0) ? str_replace('<<SPECIALIZATION CONDITION>>','',$query): str_replace('<<SPECIALIZATION CONDITION>>',' AND `doctor`.`specialization` = :sp ',$query);
$query = ($stt == 0) ? str_replace('<<STATE CONDITION>>','',$query): str_replace('<<STATE CONDITION>>',' AND `clinic`.`governorate` = :st ',$query);
$searchPDO = new PDO(DNS,ReaderUser,ReaderPass);
$searchPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$searchPDO->exec("SET CHARACTER SET utf8");
$stmt = $searchPDO->prepare($query);
if ($spc != 0) $stmt->bindParam(":sp",$spc,PDO::PARAM_INT);
if ($stt != 0) $stmt->bindParam(":st",$stt,PDO::PARAM_INT);
$stmt->bindValue(":dr",'.*'.$name.'.*',PDO::PARAM_STR);
$stmt->bindParam(":s",$ls,PDO::PARAM_INT);
$stmt->bindParam(":l",$ll,PDO::PARAM_INT);
$stmt->execute();
$Drs = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $Drs;
}
当我这样调用函数时它工作正常:
$drs = searchSubs('12', 6, '<<some Arabic name here>>' , 0, 10);
当我这样称呼它时它不会:
$SDrs = searchSubs($specialization,$state,$name,$s,$l);
在过去的两天里,我一直在寻找原因,但什么也没有,我已经对字符串变量进行了 url_decoded,$name
尝试了许多不同的方法来处理数据库中的数据类型,但也没有,