forked from AppStateESS/InternshipInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubject.php
66 lines (49 loc) · 1.3 KB
/
Subject.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
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Intern;
class Subject extends Model {
public $id;
public $abbreviation;
public $description;
public $active;
public function getDB(){
return new \PHPWS_DB('intern_subject');
}
public function getId()
{
return $this->id;
}
public function getCSV()
{
return array();
}
public function getAbbreviation()
{
return $this->abbreviation;
}
public function getName(){
return $this->description;
}
public function getActive()
{
return $this->active;
}
public static function getSubjects($mustIncludeId = null)
{
$db = PdoFactory::getPdoInstance();
$params = array();
$query = 'SELECT * from intern_subject WHERE active = 1';
if(!is_null($mustIncludeId)) {
$query .=' OR id = :mustIncludeId';
$params['mustIncludeId'] = $mustIncludeId;
}
$query .= ' ORDER BY abbreviation ASC';
$stmt = $db->prepare($query);
$stmt->execute($params);
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$subjects = array();
foreach($results as $row){
$subjects[$row['id']] = $row['abbreviation'] . ' - ' . $row['description'];
}
return $subjects;
}
}