public static function deleteAllForMember($memberId) { $conn = parent::connect(); $sql = "DELETE FROM " . TBL_ACCESS_LOG . " WHERE memberId = :memberId"; try { $st = $conn->prepare($sql); $st->bindValue(":memberId", $memberId, PDO::PARAM_INT); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public function insert() { $conn = parent::connect(); $sql = "INSERT INTO factura (id_pedido, precio) \nVALUES (:id_pedido, :precio);"; try { $st = $conn->prepare($sql); $st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT); $st->bindValue(":precio", $this->data["precio"], PDO::PARAM_STR); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function getMember($id) { $conn = parent::connect(); $sql = "SELECT * FROM " . TBL_MEMBERS . " WHERE id = :id"; try { $st = $conn->prepare($sql); $st->bindValue(":id", $id, PDO::PARAM_INT); $st->execute(); if ($row = $st->fetch()) { return new Member($row); } } catch (PDOException $e) { die("Query failed: " . $e->getMessage()); } }
public function insert() { $conn = parent::connect(); $sql = "INSERT INTO pedido_menu (id_menu, id_pedido, id_decoracion) \nVALUES (:id_menu, :id_pedido, :id_decoracion);"; try { $st = $conn->prepare($sql); $st->bindValue(":id_menu", $this->data["id_menu"], PDO::PARAM_INT); $st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT); $st->bindValue(":id_decoracion", $this->data["id_decoracion"], PDO::PARAM_INT); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public function insert() { $conn = parent::connect(); $sql = "INSERT INTO pedidos_bebidas (id_bebida, id_pedido, cantidad) \nVALUES (:id_bebida, :id_pedido, :cantidad);"; try { $st = $conn->prepare($sql); $st->bindValue(":id_bebida", $this->data["id_bebida"], PDO::PARAM_INT); $st->bindValue(":id_pedido", $this->data["id_pedido"], PDO::PARAM_INT); $st->bindValue(":cantidad", $this->data["cantidad"], PDO::PARAM_INT); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function getById($id_decoracion) { $conn = parent::connect(); $sql = "SELECT * FROM decoracion WHERE id_decoracion = :id_decoracion"; try { $st = $conn->prepare($sql); $st->bindValue(":id_decoracion", $id_decoracion, PDO::PARAM_INT); $st->execute(); $row = $st->fetch(); parent::disconnect($conn); if ($row) { return new Decoracion($row); } } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function getPrecio($id_menu) { $conn = parent::connect(); $sql = "SELECT nombre, precio FROM menu WHERE id_menu = :id_menu"; try { $st = $conn->prepare($sql); $st->bindValue(":id_menu", $id_menu, PDO::PARAM_INT); $st->execute(); $row = $st->fetch(); parent::disconnect($conn); if ($row) { return new Menu($row); } } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function getById($id_bebida) { $conn = parent::connect(); $sql = "SELECT * FROM bebidas WHERE id_bebida = :id_bebida"; try { $st = $conn->prepare($sql); $st->bindValue(":id_bebida", $id_bebida, PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); parent::disconnect($conn); if ($row) { return new Bebida($row); } } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public function insert() { $conn = parent::connect(); $sql = "INSERT INTO cliente (email, pass, nombre, apellidos, telefono) \n VALUES (:email, SHA(:pass), :nombre, :apellidos, :telefono)"; try { $st = $conn->prepare($sql); $st->bindValue(":email", $this->data["email"], PDO::PARAM_STR); $st->bindValue(":pass", $this->data["pass"], PDO::PARAM_STR); $st->bindValue(":nombre", $this->data["nombre"], PDO::PARAM_STR); $st->bindValue(":apellidos", $this->data["apellidos"], PDO::PARAM_STR); $st->bindValue(":telefono", $this->data["telefono"], PDO::PARAM_STR); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function getBebidas() { $conn = parent::connect(); $sql = "SELECT * FROM tipos_bebidas;"; try { $st = $conn->prepare($sql); $st->execute(); $tipos = array(); foreach ($st->fetchAll() as $row) { $tipos[] = new Tipo($row); } $row = $st->fetch(); parent::disconnect($conn); return array($tipos); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function getLogEntries($memberId) { $conn = parent::connect(); $sql = "SELECT * FROM " . TBL_ACCESS_LOG . " WHERE memberId = :memberId ORDER BY lastAccess DESC"; try { $st = $conn->prepare($sql); $st->bindValue(":memberId", $memberId, PDO::PARAM_INT); $st->execute(); $logEntries = array(); foreach ($st->fetchAll() as $row) { $logEntries[] = new LogEntry($row); } parent::disconnect($conn); return $logEntries; } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public static function authenticate(array $data) { $pdo = parent::connect(); if ($data['email'] != '') { $attr = 'email'; } elseif ($data['username'] != '') { $attr = 'username'; } $pass = hash_hmac('SHA256', $data['pass'], User::SALT); $table = TBL_USERS; $q = "SELECT id, username, userType, email, pass, dateAdded FROM {$table} WHERE {$attr}=:attr AND pass=:pass"; $stmt = $pdo->prepare($q); $stmt->execute(array(':attr' => $data[$attr], ':pass' => $pass)); $row = $stmt->fetch(PDO::FETCH_ASSOC); parent::disconnect($pdo); if ($row) { return new User($row); } }
public function record() { $conn = parent::connect(); $sql = "SELECT * FROM " . TBL_MESSAGE . " "; $sql .= "WHERE member_id = :member_id and message_text = :message_text and subject = :subject"; try { $st = $conn->prepare($sql); $st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT); $st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR); $st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR); $st->execute(); // var_dump($sql, $this->data, $st); if ($st->fetch()) { $sql = "UPDATE " . TBL_MESSAGE . " SET num_access = num_access + 1 "; $sql .= "WHERE member_id = :member_id and message_text = :message_text and subject = :subject"; $st = $conn->prepare($sql); $st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT); $st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR); $st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR); // var_dump($sql, $st); $st->execute(); } else { $sql = "INSERT INTO " . TBL_MESSAGE . " ( member_id, message_text, num_access, subject ) "; $sql .= " VALUES ( :member_id, :message_text, 1, :subject )"; $st = $conn->prepare($sql); $st->bindValue(":member_id", $this->data["member_id"], PDO::PARAM_INT); $st->bindValue(":message_text", $this->data["message_text"], PDO::PARAM_STR); $st->bindValue(":subject", $this->data["subject"], PDO::PARAM_STR); // var_dump($sql, $st); $st->execute(); } // var_dump($sql, $st); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public function getTravelAdvisories() { $connection = parent::connect(); $selectSQL = "SELECT * FROM TRAVELADVISORY"; $rows = $connection->query($selectSQL); $traveladvisories = array(); foreach ($rows as $row) { $traveladvisory = new traveladvisory(); $traveladvisory->setTravelAdvisoryId($row[0]); $traveladvisory->setTravelAdvisorySourceName($row[1]); $traveladvisory->setTravelAdvisorySourceLink($row[2]); $traveladvisory->setTravelAdvisorySourceLinkType($row[3]); $traveladvisories[] = $traveladvisory; } parent::disconnect($connection); return $traveladvisories; }
public function insert() { $conn = parent::connect(); $sql = "INSERT INTO pedidos (id_cliente, fecha, hora, cp, direccion, comensales) \nVALUES (:id_cliente, STR_TO_DATE(:fecha,'%d/%m/%Y'), :hora, :cp, :direccion, :comensales);"; try { $st = $conn->prepare($sql); $st->bindValue(":id_cliente", $this->data["id_cliente"], PDO::PARAM_INT); $st->bindValue(":fecha", $this->data["fecha"], PDO::PARAM_STR); $st->bindValue(":hora", $this->data["hora"], PDO::PARAM_STR); $st->bindValue(":cp", $this->data["cp"], PDO::PARAM_INT); $st->bindValue(":direccion", $this->data["direccion"], PDO::PARAM_STR); $st->bindValue(":comensales", $this->data["comensales"], PDO::PARAM_INT); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
public function getEvents() { $connection = parent::connect(); $selectSQL = "SELECT * FROM EVENT"; $rows = $connection->query($selectSQL); $events = array(); foreach ($rows as $row) { $event = new Event(); $event->setEventId($row[0]); $event->setEventType($row[1]); $event->setEventSourceName($row[2]); $event->setEventSourceLink($row[3]); $event->setEventSourceLinkType($row[4]); $events[] = $event; } parent::disconnect($connection); return $events; }
public function getNewsSources() { $connection = parent::connect(); $selectSQL = "SELECT * FROM NEWSSOURCE"; $rows = $connection->query($selectSQL); $newssources = array(); foreach ($rows as $row) { $newsSource = new NewsSource(); $newsSource->setNewsSourceId($row[0]); $newsSource->setNewsSourceName($row[1]); $newsSource->setNewsSourceLink($row[2]); $newsSource->setNewsSourceLinkType($row[3]); $newssources[] = $newsSource; } parent::disconnect($connection); return $newssources; }
public function getUsers() { $connection = parent::connect(); $selectSQL = "SELECT * FROM USER"; $rows = $connection->query($selectSQL); $users = array(); foreach ($rows as $row) { $user = new User(); $user->setUserId($row[0]); $user->setUserName($row[1]); $user->setPassword($row[2]); $users[] = $user; } parent::disconnect($connection); return $users; }
public function authenticate() { $conn = parent::connect(); $sql = "SELECT * FROM " . TBL_MEMBERS . " WHERE username = :username AND password = password(:password)"; try { $st = $conn->prepare($sql); $st->bindValue(":username", $this->data["username"], PDO::PARAM_STR); $st->bindValue(":password", $this->data["password"], PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); parent::disconnect($conn); if ($row) { return new Member($row); } } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }
/** */ public function insert() { $conn = parent::connect(); $sql = "INSERT INTO " . TBL_MEMBER . " (\n username,\n first_name,\n last_name,\n email,\n update_timestamp,\n create_timestamp\n ) VALUES (\n :username,\n :first_name,\n :last_name,\n :email,\n :update_timestamp,\n :create_timestamp\n )"; try { $st = $conn->prepare($sql); $st->bindValue(":username", $this->data["username"], PDO::PARAM_STR); $st->bindValue(":first_name", $this->data["first_name"], PDO::PARAM_STR); $st->bindValue(":last_name", $this->data["last_name"], PDO::PARAM_STR); $st->bindValue(":email", $this->data["email"], PDO::PARAM_STR); $st->bindValue(":update_timestamp", $this->data["update_timestamp"], PDO::PARAM_STR); $st->bindValue(":create_timestamp", $this->data["create_timestamp"], PDO::PARAM_STR); $st->execute(); parent::disconnect($conn); } catch (PDOException $e) { parent::disconnect($conn); die("Query failed: " . $e->getMessage()); } }