Completed
Push — master ( d015d4...c50906 )
by Mikołaj
02:42
created

AddModel::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 17
rs 9.4285
1
<?php
2
3
namespace Rudolf\Modules\Appearance\Menu;
4
5
use Rudolf\Framework\Model\AdminModel;
6
7
class AddModel extends AdminModel
8
{
9
    public function add($p)
10
    {
11
        $stmt = $this->pdo->prepare("INSERT INTO {$this->prefix}menu SET module_name = '',
12
          parent_id = :parent_id, title = :title, slug = :slug, caption = :caption,
13
          menu_type = :menu_type, item_type = :item_type, position = :position");
14
        $stmt->bindValue(':parent_id', $p['parent_id'], \PDO::PARAM_INT);
15
        $stmt->bindValue(':title', $p['title']);
16
        $stmt->bindValue(':slug', $p['slug']);
17
        $stmt->bindValue(':caption', $p['caption']);
18
        $stmt->bindValue(':menu_type', $p['menu_type']);
19
        $stmt->bindValue(':item_type', $p['item_type']);
20
        $stmt->bindValue(':position', (int) $p['position'], \PDO::PARAM_INT);
21
22
        $stmt->execute();
23
24
        return $this->pdo->lastInsertId();
25
    }
26
}
27