I have the following method for pulling out all the data from my database. However in my database there is a column called media_id. I want to make sure that it only fetches data where the media_id is unique. If there is a duplicate based on the media_id column, it just needs to pick the first one it runs into and disregard all the rest. Anyone have any suggestions how I do this? Any help is greatly appreciated.
public function getAllValuesFromOneTable($table1, $fromDate, $toDate) {
try {
$statement = $this->prepareStatement("SELECT * FROM $table1 WHERE date_of_post >= '$fromDate' AND date_of_post <= '$toDate'");
$statement->execute();
$test = $statement->fetchAll(PDO::FETCH_ASSOC);
return $test;
} catch (Exception $e) {
echo "error: " . $e->getMessage();
}
}