prepare($query);
$stmt->execute($params);
return $stmt;
} catch (Exception $e) {
return $e;
}
}
function makeTable($query, $params = null)
{
$stmt = makeStatment($query, $params);
if($stmt instanceof Exception) {
echo ''. $stmt->getMessage() .'';
} else {
// Tabelle erstellen
$meta = array();
//Spaltenüberschribt dynamisch
echo '
';
for ($i=0; $i < $stmt->columnCount(); $i++) {
$meta[] = $stmt->getColumnMeta($i);
echo ''.$meta[$i]['name'].' | ';
}
echo '
';
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo'';
foreach ($row as $r) {
echo ''.$r.' | ';
}
echo '
';
}
echo '
';
}
}
function insertInto($tablename, $columnlist, $valuelist) {
global $con;
$query = 'INSERT INTO '.$tablename.' ('.implode(',',$columnlist).') VALUES(?)';
$params = array(implode(',', $valuelist));
$stmt = makeStatment($query, $params);
if($stmt instanceof Exception) {
return $stmt;
} else {
return true;
}
}