| Conditions | 3 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public function getCandidatesByConstituencyId($constituencyId) |
||
| 18 | { |
||
| 19 | $stmt = $this->db->prepare( |
||
| 20 | "SELECT a.id, a.name, a.party FROM `tblCandidates` AS a |
||
| 21 | LEFT JOIN `tblConstituencies` AS b |
||
| 22 | ON a.constituency_id = b.id |
||
| 23 | WHERE b.id = :id |
||
| 24 | ORDER BY a.name ASC" |
||
| 25 | ); |
||
| 26 | |||
| 27 | $stmt->bindValue(':id', $constituencyId, \PDO::PARAM_INT); |
||
| 28 | |||
| 29 | $stmt->execute(); |
||
| 30 | |||
| 31 | $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
||
| 32 | |||
| 33 | if(is_array($result) && !empty($result)) { |
||
| 34 | $this->candidates = $result; |
||
| 35 | |||
| 36 | return $this->candidates; |
||
| 37 | } else { |
||
| 38 | return false; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |