我有一個表在我的數據庫具有這些字段:查詢mysql數據庫,並返回所有出現
-id
-video_title
-video_article
-video_category
現在,我想用video_category進行查詢,到目前爲止我已經試過這個代碼:
public function related_videos($current_video_category)
{
$sql = "SELECT * FROM English WHERE video_category = :current_video_category";
$stmt = $this->pdo->prepare($sql);
$result = $stmt->execute(array(":current_video_category" => $current_video_category));
$data = $stmt->fetch(PDO::FETCH_ASSOC);
return $data;
}
的問題是它只返回第一次出現,我不知道如何在一次返回$current_video_category
所有出現。
任何幫助將非常感激。
使用fetchall就像一個魅力對我來說!謝謝@MatsLindh –