Completed
Push — master ( cceadc...3df73a )
by Mikołaj
04:41
created

AddModel::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Rudolf\Modules\Users\One\Admin\Profile;
4
5
use Rudolf\Component\Auth\Auth;
6
use Rudolf\Framework\Model\AdminModel;
7
8
class AddModel extends AdminModel
9
{
10
    public function add($p)
11
    {
12
        $auth = new Auth($this->pdo, $this->prefix);
13
        $hash = $auth->getPasswordHash($p['password']);
14
15
        $stmt = $this->pdo->prepare("INSERT INTO {$this->prefix}users SET
16
            nick = :nick, first_name = :first_name, surname = :surname, email = :email,
17
            password = :password, active = :active");
18
        $stmt->bindValue(':nick', $p['nick']);
19
        $stmt->bindValue(':first_name', $p['first_name']);
20
        $stmt->bindValue(':surname', $p['surname']);
21
        $stmt->bindValue(':email', $p['email']);
22
        $stmt->bindValue(':password', $hash);
23
        $stmt->bindValue(':active', $p['active']);
24
        $stmt->execute();
25
26
        return $this->pdo->lastInsertId();
27
    }
28
}
29