prepare($sql); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayOfBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } return $arrayOfBeers; } function listLatestBreweries($pdo, $where){ $conn = $pdo; try { $sql = "SELECT * FROM brewery ORDER BY time DESC LIMIT $where"; $stmt = $conn->prepare($sql); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayOfBreweries = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Breweries: " . $e->getMessage(); } return $arrayOfBreweries; } function listLatestUsers($pdo, $where){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM user ORDER BY time DESC LIMIT $where"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayOfBreweries = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } return $arrayOfUsers; } function listLatestArticle($pdo, $where){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM article ORDER BY time DESC LIMIT $where"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayOfArticles = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } return $arrayOfArticles; } function listBeersByBrewery($pdo, $where){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM beer WHERE brewery_id = $where"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } return $arrayBeers; }