function getGamesBySearch($criteria) {
try {
$sortedBy = 'Name';
$db = getDBConnection();
$query = "SELECT *
FROM game
WHERE Name LIKE :criteria
ORDER BY :sortBy DESC";
$statement = $db->prepare($query);
$statement->bindValue(':criteria', '%'.$criteria.'%');
$statement->bindValue(':sortBy',$sortedBy);
$statement->execute();
$results = $statement->fetchAll();
$statement->closeCursor();
return $results; // Assoc Array of Rows
} catch (PDOException $e) {
$errorMessage = $e->getMessage();
include '../view/errorPage.php';
die;
}
}
For some reason, my associative array always comes back in my GameID order, when I need it to be in the order of the Name? This is only bonus for the class I am taking, but help would be appreciated.