Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. public function saveProduto(Produto $produto)
  2. {
  3. $data = array(
  4. 'nome' => $produto->nome,
  5. );
  6.  
  7. $id = (int) $produto->id;
  8.  
  9. if ($id == 0) {
  10. $this->tableGateway->insert($data);
  11. } else {
  12. if ($this->getProduto($id)) {
  13. $this->tableGateway->update($data, array('id' => $id));
  14. } else {
  15. throw new \Exception('Produto não existe');
  16. }
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement