mirror of
http://git.frickel.earth/Tysox/BOS-Pinneberg.git
synced 2026-01-08 02:13:01 +01:00
[+] Admin Webinterface
This commit is contained in:
79
libraries/database.php
Normal file
79
libraries/database.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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<65>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!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user