准备好的语句PDO返回0行

时间:2016-11-03 16:10:35

标签: php mysql pdo

var_dump($query) = string(133) "SELECT t1.*, t2.* FROM movies t1, releases t2 WHERE t1.id = t2.movieid AND title LIKE ? AND LOCATE (?, subtitles) ORDER BY added DESC"

var_dump($qqq) = array(2) { [0]=> string(9) "'%brian%'" [1]=> string(9) "'English'" }

$stmt = $pdo->prepare($query);
if ($stmt->execute($qqq)){
    echo $stmt->rowCount();
}else{
    echo "Not";
}

返回0,查询有效,但没有结果。 如果我跑" SELECT t1.*, t2.* FROM movies t1, releases t2 WHERE t1.id = t2.movieid AND title LIKE '%brian%' AND LOCATE ('English', subtitles) ORDER BY added DESC"在phpmyadmin我得到了结果。我不知道在哪里看,检查我所知道的一切。

1 个答案:

答案 0 :(得分:2)

您不应该在参数中包含引号。 $qqq应如下所示:

$qqq = array("%brian%", "English");