ValidateLinkDAO::addValidateLink()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 15
nc 1
nop 3
dl 0
loc 20
rs 9.7666
c 0
b 0
f 0
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