Commit 2529cd37 authored by Leif Andersson's avatar Leif Andersson
Browse files

Flyttade definitionen av $personFields till class.AddressDB.php

parent 31dfdf6c
......@@ -3,7 +3,7 @@
class AddressDB {
private static $instance;
private $PDB;
private $database = 'NyAdresser';
private static $database = 'NyAdresser';
private function __construct() {
global $gCms;
......@@ -14,7 +14,7 @@ class AddressDB {
$result = $this->PDB->Connect($config['db_hostname'],
$config['db_username'],
$config['db_password'],
$this->database);
self::$database);
if ($result) {
$result = $this->PDB->Execute("SET NAMES 'utf8'");
} else {
......@@ -30,4 +30,19 @@ class AddressDB {
}
return self::$instance->PDB;
}
public static function getFields($tableName) {
$db = self::getDB();
$query = 'select column_name from information_schema.columns where '
. 'table_schema="'. self::$database . '" and table_name=?';
$values = array($tableName);
$result = $db->Execute($query,$values);
if ($result === false) { die("Database error!<br>" . $db->ErrorMsg()); }
$fields = array();
while ($row = $result->FetchRow()) {
$fields[] = $row['column_name'];
}
return $fields;
}
}
......@@ -18,23 +18,16 @@ EOT;
Grupper.ID=GruppID and AdressID = ?
EOT;
/* private static $queryUpdate = <<<EOT */
/* update Adresser set */
/* EOT; */
public static $firstFields = array(
'ID','fornamn', 'efternamn', 'foretag','avdelning', 'adress', 'Grupp');
private static $personFields = array(
'ID', 'Fornamn', 'Efternamn', 'Titel', 'Personnummer', 'SkolaForetag',
'Avdelning', 'Adress', 'Besok', 'Hem', 'Epost', 'Telefon', 'TelefonMobil',
'TelefonHem', 'URL', 'AnknytningTillInst', 'DiverseInfo', 'Andrad');
private static $personFields;
public function __construct($param = NULL) {
global $gCms;
if (!isset($gCms)) exit;
global $gCms; if (!isset($gCms)) exit;
if (!isset(self::$personFields)) {
self::$personFields = AddressDB::getFields('Adresser');
}
foreach(self::$personFields as $field) {
$this->$field = '';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment