forked from bagvendt/vaip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmployeeFactory.php
55 lines (48 loc) · 943 Bytes
/
EmployeeFactory.php
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
<?php
/**
* An Employee
* @author Softbox
*
*/
class Employee {
var $employeeID;
var $name;
var $address;
var $email;
var $phone;
/**
*Constructs an employee
*/
function __construct($id,$name,$address,$email,$phone)
{
$this->employeeID = $id;
$this->name = $name;
$this->address = $address;
$this->email = $email;
$this->phone = $phone;
}
/**
* Returns the id of this employee
* @return the employeeID
*/
function getID()
{
return $this->employeeID;
}
}
class EmployeeFactory
{
function createEmployee($empID)
{
$host = 'localhost';
$username = 'root';
$password = 'tisimunden';
$database = 'fadl';
mysql_connect($host, $username, $password);
mysql_select_db($database);
$result = mysql_query('SELECT * FROM employee WHERE empid = '. $empID);
$row = mysql_fetch_assoc($result);
return new Employee ($empID , $row['name'] , $row['address'], $row['email'] , $row['phone']);
}
}
?>