Conditions | 3 |
Paths | 2 |
Total Lines | 23 |
Code Lines | 9 |
Lines | 23 |
Ratio | 100 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public function getResults() |
||
18 | { |
||
19 | $stmt = $this->db->query( |
||
20 | "SELECT a.name, a.party, a.constituency_id, c.name AS constituency, COUNT(*) AS count |
||
21 | FROM tblCandidates AS a |
||
22 | INNER JOIN tblVotes AS b |
||
23 | ON a.id = b.candidate_id |
||
24 | LEFT JOIN tblConstituencies AS c |
||
25 | ON a.constituency_id = c.id |
||
26 | GROUP BY b.candidate_id |
||
27 | ORDER BY count DESC, constituency ASC" |
||
28 | ); |
||
29 | |||
30 | $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
||
31 | |||
32 | if(is_array($result) && !empty($result)) { |
||
33 | $this->results = $result; |
||
34 | |||
35 | return $this->results; |
||
36 | } else { |
||
37 | return false; |
||
38 | } |
||
39 | } |
||
40 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.