3
我寫這篇全文搜索功能,但它拋出我這個錯誤:OOP PDO語句錯誤
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1.
我是新來的OOP & PDO, 是我在正確的語法準備發言?還是我在其他地方出錯了? 我是否在查詢中實現了:q參數?
public function searchFullTextPanel($q)
{
try
{
$stmt=$this->db->prepare("SELECT id,firstname,lastname,adresse_str,adresse_plz,adresse_ort,adresse_land,telefon,email,image_name FROM partner WHERE MATCH (firstname,lastname,adresse_str,adresse_plz,adresse_ort,adresse_land,telefon,email) AGAINST :q");
$stmt->bindparam(":q",$q);
$stmt->execute();
if($stmt->rowCount()>0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
// doing stuff
}
}
else
{
?>
<tr>
<td>fml...</td>
</tr>
<?php
}
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
是的,這是問題,tyvm! – girax