class Passport extends Document private number null public passport_id

 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
class Passport extends Document {
private $number = null;
public $passport_id = null;
public function setDocumentNumber($number) {
$this->number = $number;
}
public function save() {
$db = Database::getInstance();
$query = "INSERT INTO passports ('name', 'birth_date') VALUES ($this->viza_data) RETURNING id;";
if ($result = pg_query($db, $query)) {
$db->close();
$this->passport_id = $result;
return true;
}
return false;
}
}
class ForeignPassport extends Passport {
private $viza_data = array();
public function addVizaData(array $data) {
$data['passport_id'] = parent::$passport_id;
$this->viza_data = array_merge($data, $this->viza_data);
}
public function save() {
$db = Database::getInstance();
$query = "INSERT INTO foreign_passports ('passport_id', 'country', 'date') VALUES ($this->viza_data)";
if ($result = pg_query($db, $query)) {
$db->close();
return true;
}
return false;
}
}