を働いていない私は与えられた映像ため、同じジャンル、国から関連するビデオタイトルを返すクエリを持って、日付は公表などPDOのMySQL「)(ではない」
。問題は、クエリで排除したい動画が返され、配列内で最初にソートされることです。なぜこうなった?
public function interval($month, $not, $limit) {
$this->not = array_unique($not);
$i = implode(',', $this->not);
echo $i;//prints: onajr,babyjem,posh
$query = '
select title, artists, published, views, video_name, yt_id, duration, play_start, genre, country from videos
where
published BETWEEN :published - INTERVAL :month MONTH AND :published + INTERVAL :month MONTH
and MATCH(country) AGAINST(:country IN boolean mode)
and MATCH(genre) AGAINST(:genre IN boolean mode)
and
video_name not in (" :i ")
ORDER BY RAND() limit :limit
';
$run_query = $this->pdo->prepare($query);
$run_query->bindValue(':published', $this->published);
$run_query->bindValue(':country', '+' . $this->data->country);
$run_query->bindValue(':genre', '+' . $this->data->genre);
$run_query->bindValue(':limit', $limit, PDO::PARAM_INT);
$run_query->bindValue(':month', $month, PDO::PARAM_INT);
$run_query->bindValue(':i', $i);
$run_query->execute();
$data = $run_query->fetchAll(PDO::FETCH_ASSOC);
print_r($data);
//contains all three of them onajr,babyjem,posh
}
'video_nameではない(:i)' –
Gここで@MichaelBerkowskiのコメントを追加することを心配しています。「PDOはコンマ区切りのリストをIN()リストに展開することはしませんが、IN()に単一の文字列値として扱いますリテラル '、' '' $ i'とバインディングを動的に構築する必要があります。プレースホルダあたり1つの値。 – chris85
それぞれの 'video_name'を別々にバインドしますか? @AlonEitanのコメントはうまくいきます。 –