mirror of
http://git.frickel.earth/Tysox/BOS-Pinneberg.git
synced 2025-05-20 23:14:30 +02:00
79 lines
1.4 KiB
PHP
79 lines
1.4 KiB
PHP
<?php
|
|
|
|
class database{
|
|
|
|
public $host = DB_HOST;
|
|
public $user = DB_USER;
|
|
public $pass = DB_PASS;
|
|
public $db_name = DB_NAME;
|
|
|
|
public $link;
|
|
public $error;
|
|
|
|
//Creating constructor
|
|
public function __construct(){
|
|
|
|
$this->connect();
|
|
}
|
|
|
|
//Connecting
|
|
private function connect(){
|
|
|
|
$this->link = new mysqli($this->host, $this->user, $this->pass, $this->db_name);
|
|
|
|
if(!$this->link){
|
|
$this->error = "Connection Failed: ". $this->link->connect_error;
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
//select query
|
|
public function select($query){
|
|
|
|
$result = $this->link->query($query);
|
|
|
|
if($result->num_rows > 0){
|
|
return $result;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
//insert query
|
|
public function insert($query){
|
|
|
|
$insert = $this->link->query($query);
|
|
if($insert){
|
|
header("location: index.php?msg=Eintrag hinzugefügt!");
|
|
}
|
|
else {
|
|
echo "Konnte nicht eingetragen werden!";
|
|
}
|
|
}
|
|
|
|
// update query
|
|
public function update($query){
|
|
|
|
$update = $this->link->query($query);
|
|
if($update){
|
|
header("location: index.php?msg=Eintrag überarbitet!");
|
|
}
|
|
else {
|
|
echo "Konnte nicht überarbeitet werden!";
|
|
}
|
|
}
|
|
|
|
// delete query
|
|
public function delete($query){
|
|
|
|
$delete = $this->link->query($query);
|
|
if($delete){
|
|
header("location: index.php?msg=Eintrag gelöscht!");
|
|
}
|
|
else {
|
|
echo "Konnte nicht gelöscht werden!";
|
|
}
|
|
}
|
|
|
|
} |