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; } function listTagsByBeer($pdo, $beer){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT tag_title FROM beer_has_tag INNER JOIN tag ON beer_has_tag.tag_id = tag.id WHERE beer_id = '$beer'"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayBeersXTags = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } return $arrayBeersXTags; } function listBeersByTagID($pdo, $tag){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT FROM beer_has_tag JOIN tag ON tag_id WHERE tag.id = $tag"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayTagsXBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } print_r($arrayTagsXBeers); return $arrayTagsXBeers; } function listBeersByUser($pdo, $user){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT name, beer.id, degree, rating FROM beer JOIN list ON beer.id = list.beer_id JOIN user ON list.user_id = user.id WHERE user.id = $user"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayOfBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } return $arrayOfBeers; } function listBreweriesNAN( $pdo ){ $conn = $pdo; try { $sql = "SELECT * FROM brewery"; $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 listBeersNAN( $pdo ){ $conn = $pdo; try { $sql = "SELECT * FROM beer"; $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 listBeersByTag($pdo, $tag){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM beer_has_tag JOIN tag ON tag_id WHERE tag_title LIKE $tag"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayTagsXBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } print_r($arrayTagsXBeers); return $arrayTagsXBeers; } function listBeersByName($pdo, $name){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM beer WHERE name LIKE $name"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayTagsXBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } print_r($arrayTagsXBeers); return $arrayTagsXBeers; } function listBreweryByName($pdo, $name){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM brewery WHERE name LIKE $name"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayTagsXBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } print_r($arrayTagsXBeers); return $arrayTagsXBeers; } function listArticleByName($pdo, $title){ $conn = $pdo; try { $stmt = $conn->prepare("SELECT * FROM article WHERE title LIKE $title"); $stmt->execute(); $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $arrayTagsXBeers = $stmt->fetchAll(); } catch (PDOException $e) { echo "Error in Beers: " . $e->getMessage(); } print_r($arrayTagsXBeers); return $arrayTagsXBeers; }