Пример #1
0
 public function postEdit($req)
 {
     $c = new Category();
     $c->fill($_POST);
     $c->id = $req->id;
     $result = $c->save();
     if ($result) {
         $this->service->flash('The category was edited.', 'success');
     } else {
         $this->service->flash('Can\'t edit the category.', 'alert');
     }
     return $this->service->back();
 }
Пример #2
0
 public function getById($id)
 {
     $pdo = Config::getInstance()->get('db.pdo');
     $stmt = $pdo->prepare('SELECT * FROM categories WHERE id = :id LIMIT 1');
     $result = $stmt->execute(['id' => $id]);
     if ($result) {
         $category = $stmt->fetch();
         $c = new Category();
         $c->fill($category);
         return $c;
     }
     return null;
 }