ContinentDAO::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace AL\Common\DAO;
3
4
require_once __DIR__."/../../lib/Db.php" ;
5
require_once __DIR__."/../Model/Continent/Continent.php" ;
6
7
/**
8
 * DAO for Continent
9
 */
10
class ContinentDAO {
11
    private $mysqli;
12
13
    public function __construct($mysqli) {
14
        $this->mysqli = $mysqli;
15
    }
16
17
    /**
18
     * Get all the continents
19
     * @return \AL\Common\Model\Continent\Continent[] An array of Continents
20
     */
21
    public function getAllContinents() {
22
        $stmt = \AL\Db\execute_query(
23
            "ContinentDAO: getAllContinents",
24
            $this->mysqli,
25
            "SELECT continent_id, continent_name
26
            FROM continent
27
            ORDER BY continent_id ASC",
28
            null, null
29
        );
30
31
        \AL\Db\bind_result(
32
            "ContinentDAO: getAllContinents",
33
            $stmt,
34
            $id, $name
35
        );
36
37
        $continents = [];
38
        while ($stmt->fetch()) {
39
            $continents[] = new \AL\Common\Model\Continent\Continent(
40
                $id,
41
                $name
42
            );
43
        }
44
45
        $stmt->close();
46
47
        return $continents;
48
    }
49
}
50