1
0
mirror of https://github.com/Mowie/Database-Class.git synced 2024-11-08 08:29:58 +00:00
Database-Class/db-blank.php

150 lines
2.2 KiB
PHP
Raw Normal View History

2016-07-31 12:28:41 +00:00
<?php
/*
* Min PHP Version: 4
*/
class db
{
//Init
private $host;
private $dbname;
private $usr;
private $pass;
private $dbh;
private $prefix;
public $data;
//Datenbankverbindung aufbauen
function __construct($host, $dbname, $usr, $pass, $prefix = '')
{
$this->host = $host;
$this->dbname = $dbname;
$this->usr = $usr;
$this->pass = $pass;
$this->prefix = $prefix;
}
private $col = null;
public function setCol($col)
{
$this->col = $col;
}
//Daten holen
public function get($where = [], $link = 'AND')
{
if (isset($this->col))
{
//Entweder übergebene Daten oder in $this->data vorhandene nutzen
if (empty($where))
{
if (empty($this->data))
{
$where = [];
} else
{
$where = $this->data;
}
}
//
}
}
//Daten einfügen
public function insert($args = [])
{
if (isset($this->col))
{
//Entweder übergebene Daten oder in $this->data vorhandene nutzen
if (empty($args))
{
if (empty($this->data))
{
$args = [];
} else
{
$args = $this->data;
}
}
if (!empty($args))
{
}
}
}
public function lastID()
{
return $this->dbh->lastInsertId();
}
//Daten Updaten
public function update($where = [], $dataToUpdate = [], $link = 'AND')
{
if (isset($this->col))
{
//Entweder übergebene Daten oder in $this->data vorhandene nutzen
if (empty($dataToUpdate))
{
if (empty($this->data))
{
$dataToUpdate = [];
} else
{
$dataToUpdate = $this->data;
}
}
}
}
//Daten Löschen
public function delete($where = [], $link = 'AND')
{
if (isset($this->col))
{
//Entweder übergebene Daten oder in $this->data vorhandene nutzen
if (empty($where))
{
if (empty($this->data))
{
$where = [];
}
else
{
$where = $this->data;
}
}
}
}
2016-07-31 17:39:53 +00:00
//Create Table
public function createCol($name, $rows)
{
$dataTypes = ['int' => 'bigint(11) NOT NULL', 'string' => 'text CHARACTER SET utf8 NOT NULL', 'longstring' => 'longtext CHARACTER SET utf8 NOT NULL', 'boolean' => 'tinyint(1) NOT NULL'];
}
//Version
public function version()
{
}
2016-07-31 12:28:41 +00:00
//Aufräumen
public function clear()
{
$this->col = null;
$this->data = '';
}
}