Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("../config.php");
- class db
- {
- public $host;
- public $user;
- public $pass;
- public $data;
- public $conn;
- public $table;
- function db()
- {
- global $servername, $dbusername, $dbpassword, $dbname;
- $this->host=$servername;
- $this->user=$dbusername;
- $this->pass=$dbpassword;
- $this->data=$dbname;
- $this->conn=new mysqli($this->host, $this->user, $this->pass, $this->data);
- }
- public function connect()
- {
- if(!$this->conn)
- {
- return mysqli_error();
- }
- $sel=mysqli_select_db($this->conn, $this->data);
- if(!$sel)
- {
- return mysqli_error();
- }
- }
- public function insertCategory($name)
- {
- $query=mysqli_query($this->conn, "INSERT INTO categories(name) VALUES('$name')");
- if ($query) {
- return "Rij is succesvol toegevoegd.";
- } else {
- return "Error: " . mysqli_error($this->conn);
- }
- }
- public function updateCategory($id, $name)
- {
- $query=mysqli_query($this->conn, "UPDATE categories SET name='$name' WHERE id='$id'");
- if ($query) {
- return "Rij is succesvol veranderd.";
- } else {
- return "Error: " . mysqli_error($this->conn);
- }
- }
- public function deleteCategory($id)
- {
- $query=mysqli_query($this->conn, "DELETE FROM categories WHERE id='$id'");
- if ($query) {
- return "Rij is succesvol verwijderd.";
- } else {
- return "Error: " . mysqli_error($this->conn);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement