Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function whitelist($institution) |
||
29 | { |
||
30 | // Does the whitelist entry exist? |
||
31 | $stmt = $this->connection->prepare('SELECT * FROM whitelist_entry WHERE institution=:institution LIMIT 1'); |
||
32 | $stmt->bindParam('institution', $institution, PDO::PARAM_STR); |
||
33 | $stmt->execute(); |
||
34 | if ($stmt->rowCount() === 0) { |
||
35 | $sql = "INSERT INTO whitelist_entry (`institution`) VALUES (:institution);"; |
||
36 | $stmt = $this->connection->prepare($sql); |
||
37 | $data = ['institution' => $institution]; |
||
38 | if ($stmt->execute($data)) { |
||
39 | return $data; |
||
40 | } |
||
41 | throw new Exception('Unable add the institution to the whitelist'); |
||
42 | } else { |
||
43 | // Return the existing whitelist data |
||
44 | return reset($stmt->fetchAll()); |
||
|
|||
45 | } |
||
46 | } |
||
47 | } |
||
48 |