<?php
class DataInterface
{
private $db;
private $verbindingOk;
private $dbdata;
private $result;
public function __construct()
{
$this->verbindingOk = false;
if($this->db = mysqli_connect("localhost", "zwobbel", "test"))
$this->verbindingOk = true;
mysqli_select_db($this->db,"yves");
}
public function __destruct()
{
mysqli_close($this->db);
}
public function isVerbonden()
{
return $this->verbindingOk;
}
public function Verbinding()
{
return $this->db;
}
public function insertFunction($values, $table) {
$sQuery_fields = "SHOW COLUMNS FROM " . $table;
try {
if (!isset(self::$aTableFields[$table])) {
self::$aTableFields[$table] = $this->db->query("SHOW COLUMNS FROM " . $table);
}
$sFields = '';
$sValues = '';
$looped = 1;
foreach (self::$aTableFields[$table] as $r)
{
$aFields[$r[0]] = '';
}
foreach ($values as $key => $value) {
if ($looped < $count) {
$sFields .= $key . ', ';
$sValues .= "'" .$value. "',";
} elseif ($looped == $count) {
$sFields .= $key;
$sValues .= "'" .$value. "'";
}
}
$looped++;
}
$sQuery = "INSERT INTO " .$table. " (" .$sFields. ") VALUES (" .$sValues. ")";
$rResult = $this->db->query($sQuery);
return $aFields;
} catch (Exception $e) {
return false;
}
}
}
?>