Warning: Cannot modify header information - headers already sent by (output started at /var/www/jonas-eriksen.dk/pic/private/index.php:1) in /var/www/jonas-eriksen.dk/pic/private/index.php on line 215
conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
public function test()
{
echo 'test';
}
public function get_latest_input()
{
try {
$stmt = $this->conn->prepare("SELECT * FROM anfald ORDER BY date DESC LIMIT 1;");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt->fetch();
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
public function get_all()
{
try {
$stmt = $this->conn->prepare("SELECT * FROM anfald ORDER BY date DESC;");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt->fetchAll();
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
public function insert($date, $faint, $twitch, $feeling, $comment)
{
try {
$stmt = $this->conn->prepare("INSERT INTO anfald (date, faint, twitch, feeling, comment)
VALUES (UNIX_TIMESTAMP(:date), :faint, :twitch, :feeling, :comment)");
$stmt->bindParam(':date', $date);
$stmt->bindParam(':faint', $faint);
$stmt->bindParam(':twitch', $twitch);
$stmt->bindParam(':feeling', $feeling);
$stmt->bindParam(':comment', $comment);
$stmt->execute();
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
}
}