Esempio n. 1
0
function getUsersAttendingEvent($name)
{
    global $db;
    if (!existEvent($name)) {
        return -1;
    }
    $stmt = $db->prepare('SELECT idEvent FROM Event WHERE name = :name');
    $stmt->bindParam(':name', $name, PDO::PARAM_STR);
    $stmt->execute();
    $result = $stmt->fetch();
    $idEvent = $result['idEvent'];
    $stmt = $db->prepare('SELECT User.username FROM AttendEvent,User WHERE idEvent = :id AND User.idUser=AttendEvent.idUser');
    $stmt->bindParam(':id', $idEvent, PDO::PARAM_INT);
    $stmt->execute();
    $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (count($result) < 1) {
        return false;
    }
    return $result;
}
Esempio n. 2
0
<?
  include_once('../database/eventFunc.php'); 
  

  try {
    $exist = existEvent($_POST['name']);
    if ($exist === false){
      echo "fail";
    }
    else if ($exist === true){
      $idEvent = getEventId($_POST['name']);
      if ($idEvent == -1){
        echo "fail";
      }
      else
        echo $idEvent;
    }
  } catch (PDOException $e) {
    die($e->getMessage());
  }
?>