<?php

include_once "User.php";
include_once "config.php";

use \User as User;

function open_db() {
    global $DB, $DB_USER, $DB_PASS;
    try {
        # MS SQL Server and Sybase with PDO_DBLIB 
        $DBH = new PDO($DB, $DB_USER, $DB_PASS);
    }
    catch(PDOException $e) {
        echo $e->getMessage();
    }
    return $DBH;
}

function db_add_user(User $user)
{
    $DBH = open_db();
    $columns = getColumnNames($DBH, "person");
    foreach ((array) $user as $key => $value) {
        if (array_key_exists($key, (array) $columns)) {
            $a[$key] = $value;
        }
    }
    $keys = array_keys($a);
    $sql = "INSERT INTO person (".implode(", ",$keys).") \n";
    $sql .= "VALUES ( :".implode(", :",$keys).")";
    $q = $DBH->prepare($sql);
    $i=1;
    foreach($a as $value)
        $q->bindParam($i++, $value);
    print $sql. "\n";
    return $q->execute($a);
}

function getColumnNames($dbh, $table)
{
    $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :table";
    try {
        $stmt = $dbh->prepare($sql);
        $stmt->bindValue(':table', $table, PDO::PARAM_STR);
        $stmt->execute();
        $output = array();
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $output[$row['COLUMN_NAME']] = $row['COLUMN_NAME'];
        }
        return $output;
    } catch (PDOException $pe) {
        trigger_error('Could not connect to MySQL database. ' . $pe->getMessage(), E_USER_ERROR);
    }
}

try {
    # MS SQL Server and Sybase with PDO_DBLIB 
    $DBH = new PDO($DB, $DB_USER, $DB_PASS);
    $table = "person";
    $sql = "SHOW COLUMNS FROM " . $table;
    $stmt = $DBH->prepare($sql);
    # $stmt->bindValue(':table', $table, PDO::PARAM_STR);
    $stmt->execute();
    $output = array();
    while($row = $stmt->fetch(PDO::FETCH_NUM)){
        $output[] = $row[0];
        print $row[0] . "\n";
        }
    }
  catch(PDOException $e) {
      echo $e->getMessage();
  }

  $user=new User();
  $user->username="test";
  print $user->to_string();
  db_add_user($user);
