Пример #1
0
 public function salvare(Utenti $utenti)
 {
     $data = array('nome' => $utenti->getNome(), 'email' => $utenti->getEmail(), 'password' => $utenti->getPassword(), 'immagine' => $utenti->getImmagine(), 'stato' => $utenti->getStato());
     $id = (int) $utenti->getId();
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->tuttiPerId($id)) {
             if ($data['immagine'] == null) {
                 $this->tableGateway->update(array('id' => $id), array('nome' => $data['nome']), array('email' => $data['email']), array('stato' => $data['stato']), array('password' => $data['password']));
             } else {
                 $this->tableGateway->update($data, array('id' => $id));
             }
         } else {
             throw new \Exception('ID form non esistente');
         }
     }
 }
Пример #2
0
 public function eliminarAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('admin', array('controller' => 'utenti', 'action' => 'index'));
     }
     $producto = new Utenti();
     $producto->setId($id);
     $this->getUtentiDao()->eliminare($producto);
     return $this->redirect()->toRoute('admin', array('controller' => 'utenti', 'action' => 'index'));
 }