OOP
Voorbeeld database object:
class Database
{
// sql host
private $host = 'localhost';
// sql gebruikersnaam
private $username = 'root';
// sql wachtwoord
private $password = '';
// db connectie
private $conn;
// sql errors
private $errors = array();
public function getQueryList($query)
{
}
public function getQueryRow($query)
{
}
public function getDb()
{
// maak verbinding
$this->conn = new mysqli($this->host, $this->username, $this->password);
// controleer of verbinding is gelukt
if ($this->conn->connect_error) {
$this->setError("Connectie mislukt: " . $this->conn->connect_error);
return false;
}
return true;
}
public function updateQuery($query)
{
}
public function insertQuery($query)
{
}
public function setError($error)
{
$this->errors[] = $error;
}
public function getErrors()
{
return $this->errors;
}
}