<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
This code is published under a 0BSD license.
Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
*/
require_once('inc/base.php');
require_once('inc/error.php');
require_once('inc/debug.php');
class DB extends PDO
{
public function __construct()
{
$dsn = "mysql:host=" . config('db_host', true);
if (config('db_port', true)) {
$dsn .= ';port=' . config('db_port', true);
}
if (config('db_socket', true)) {
$dsn = "mysql:unix_socket=" . config('db_socket', true);
}
$username = config('db_user', true);
$password = config('db_pass', true);
parent::__construct($dsn, $username, $password, [PDO::ATTR_TIMEOUT => "30"]);
}
/*
Wenn Parameter übergeben werden, werden Queries immer als Prepared statements übertragen
*/
public function myquery($stmt, $params = null, $allowempty = false)
{
if (is_array($params)) {
if (config("enable_debug") && !$allowempty) {
foreach (array_values($params) as $p) {
if ($p === '') {
DEBUG("Potential bug, empty string found in database parameters");
warning("Potential bug, empty string found in database parameters");
}
}
}
$response = parent::prepare($stmt);
$response->execute($params);