You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
851 B
PHP
32 lines
851 B
PHP
<?php
|
|
|
|
function getRecord($pdo, $from, $where ){
|
|
$conn = $pdo;
|
|
try {
|
|
$sql = "SELECT * FROM $from WHERE id = $where";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute();
|
|
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
|
|
$record = $stmt->fetch();
|
|
} catch (PDOException $e) {
|
|
echo "Error in $from: Not Found";
|
|
}
|
|
return $record;
|
|
}
|
|
|
|
function isThisBound($pdo, $where, $item_id, $user_id){
|
|
$conn = $pdo;
|
|
try {
|
|
if($where === "list"){
|
|
$item = "beer_id";
|
|
}else $item = "brewery_id";
|
|
$sql = "SELECT * FROM $where WHERE $item = $item_id AND user_id = $user_id";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute();
|
|
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
|
|
if($stmt->rowCount() == 1)return true;
|
|
else return false;
|
|
} catch (PDOException $e) {
|
|
echo "Error in $where: Not Found";
|
|
}
|
|
} |