c_personAdmin.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
require_once PICTOOL_SAVANT;
require_once LIBDIR . 'c_mysqlDb.php';
require_once LIBDIR . 'errException.php';
require_once LIBDIR . 'c_person.php';
class c_personAdmin extends c_picToolSavant
{
private $dbHandle = NULL;
private $_persons;
function __construct ($locale = NULL)
{
parent::__construct ();
setErrExceptionMapping ();
try
{
$this->dbHandle = new c_mysqlDb (
self::DBHOST, self::DBUSER, self::DBPASS, self::DBNAME);
if (is_string ($locale))
$this->dbHandle->setLocale ($locale);
}
catch (Exception $e)
{
if ($this->dbHandle !== NULL)
unset ($this->dbHandle);
print "<pre>\n";
print "Konnte Datenbank nicht initialisieren!\n";
print $e;
print "</pre>\n";
exit (1);
}
resetErrExceptionMapping ();
$this->_persons = $this->getPersons ();
}
function __destruct ()
{
if (isset ($this->persons))
unset ($this->persons);
if ($this->dbHandle !== NULL)
unset ($this->dbHandle);
}
//private function getPersons ()
function getPersons ()
{
$result = NULL;
setErrExceptionMapping ();
try
{
$resId = $this->dbHandle->query (
'SELECT * from personsView ORDER BY surname, firstname');
$_result = $this->dbHandle->getObject (
$resId, 'c_person', array (NULL));
$this->dbHandle->freeResult ($resId);
}
catch (Exception $e)
{
print "jokus<br/>";
if (isset ($_result))
unset ($_result);
if (isset ($resId))
$this->dbHandle->freeResult ($resId);
print "<pre>";
print $e;
print "</pre>";
}
resetErrExceptionMapping ();
foreach ($_result as $res)
$result[$res->get_personId ()] = $res;
unset ($_result);
return $result;
}
function personSearch ()
{
$names = array ();
foreach ($this->_persons as $person)
$names[$person->get_surname ()][] =
array ($person->get_firstname (), $person);
$this->assign ('names', $names);
return $this->fetch ('personAdmin/personSearch.tpl.php');
}
function personForm ()
{
return $this->fetch ('personAdmin/personForm.tpl.php');
}
function show ()
{
$this->assign ('personSearch', $this->personSearch ());
$this->assign ('personForm', $this->personForm ());
$this->display ('personAdmin/personAdmin.tpl.php');
}
};
?>