我正在尝试在 PDO Mydql 中使用 REGEXP 但有问题
function artist_list($artist){
global $DBH;
$STH = $DBH->prepare("SELECT songs ,image ,artist,album,r_year
FROM english_fm
WHERE artist REGEXP \"^[:artist]\"
GROUP BY artist order by slno");
$STH->bindValue(":artist" , "$artist", PDO::PARAM_STR);
$STH->execute();
$STH->setFetchMode(PDO::FETCH_ASSOC);
return $STH;
$DBH = Null;
}
这在我使用时不起作用,REGEXP \"^[:artist]\"
但如果我使用
REGEXP \"^[$artist]\"
有用
function artist_list($artist){
global $DBH;
$STH = $DBH->prepare("SELECT songs ,image ,artist,album,r_year
FROM english_fm
WHERE artist REGEXP \"^[$artist]\"
GROUP BY artist order by slno");
$STH->bindValue(":artist" , "$artist", PDO::PARAM_STR);
$STH->execute();
$STH->setFetchMode(PDO::FETCH_ASSOC);
return $STH;
$DBH = Null;
}
请帮忙