ValidateLinkDAO   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addValidateLink() 0 20 1
A __construct() 0 2 1
1
<?php
2
namespace AL\Common\DAO;
3
4
require_once __DIR__."/../../lib/Db.php" ;
5
6
/**
7
 * DAO for links submitted by users that need to be validated
8
 */
9
class ValidateLinkDAO {
10
    private $mysqli;
11
12
    public function __construct($mysqli) {
13
        $this->mysqli = $mysqli;
14
    }
15
16
    /**
17
     * Add a new link to validate
18
     *
19
     * @param  string $name        Name of the link
20
     * @param  string $url         URL of the link
21
     * @param  string $description Description of the link
22
     * @return integer ID of the inserted link to validate
23
     */
24
    public function addValidateLink($name, $url, $description) {
25
        $stmt = \AL\Db\execute_query(
26
            "ValidateLinkDAO: Add link",
27
            $this->mysqli,
28
            "INSERT INTO website_validate (
29
                website_name,
30
                website_url,
31
                website_date,
32
                website_description,
33
                user_id
34
            )
35
            VALUES (?, ?, ?, ?, ?)",
36
            "ssiss", $name, $url, time(), $description, $_SESSION['user_id']
37
        );
38
39
        $id = $stmt->insert_id;
40
41
        $stmt->close();
42
43
        return $id;
44
    }
45
}
46