| @@ 10-26 (lines=17) @@ | ||
| 7 | ||
| 8 | class ItemAddModel extends AdminModel |
|
| 9 | { |
|
| 10 | public function add($p) |
|
| 11 | { |
|
| 12 | $stmt = $this->pdo->prepare("INSERT INTO {$this->prefix}menu SET module_name = '', |
|
| 13 | parent_id = :parent_id, title = :title, slug = :slug, caption = :caption, |
|
| 14 | menu_type = :menu_type, item_type = :item_type, position = :position"); |
|
| 15 | $stmt->bindValue(':parent_id', $p['parent_id'], \PDO::PARAM_INT); |
|
| 16 | $stmt->bindValue(':title', $p['title']); |
|
| 17 | $stmt->bindValue(':slug', !empty($p['slug']) ? $p['slug'] : Text::sluger($p['title'])); |
|
| 18 | $stmt->bindValue(':caption', $p['caption']); |
|
| 19 | $stmt->bindValue(':menu_type', $p['menu_type']); |
|
| 20 | $stmt->bindValue(':item_type', $p['item_type']); |
|
| 21 | $stmt->bindValue(':position', (int) $p['position'], \PDO::PARAM_INT); |
|
| 22 | ||
| 23 | $stmt->execute(); |
|
| 24 | ||
| 25 | return $this->pdo->lastInsertId(); |
|
| 26 | } |
|
| 27 | } |
|
| 28 | ||
| @@ 28-43 (lines=16) @@ | ||
| 25 | ]); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function edit($id, $p) |
|
| 29 | { |
|
| 30 | $stmt = $this->pdo->prepare("UPDATE {$this->prefix}menu SET |
|
| 31 | parent_id = :parent_id, title = :title, slug = :slug, caption = :caption, menu_type = :menu_type, |
|
| 32 | item_type = :item_type, position = :position WHERE id = :id"); |
|
| 33 | $stmt->bindValue(':parent_id', $p['parent_id'], \PDO::PARAM_INT); |
|
| 34 | $stmt->bindValue(':title', $p['title']); |
|
| 35 | $stmt->bindValue(':slug', !empty($p['slug']) ? $p['slug'] : Text::sluger($p['title'])); |
|
| 36 | $stmt->bindValue(':caption', $p['caption']); |
|
| 37 | $stmt->bindValue(':menu_type', $p['menu_type']); |
|
| 38 | $stmt->bindValue(':item_type', $p['item_type']); |
|
| 39 | $stmt->bindValue(':position', (int) $p['position'], \PDO::PARAM_INT); |
|
| 40 | $stmt->bindValue(':id', $id, \PDO::PARAM_INT); |
|
| 41 | ||
| 42 | return $stmt->execute(); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||