Advertisement
Guest User

Untitled

a guest
May 29th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. namespace Seu\Namespace\;
  3.  
  4. use Seu\Namespace\Cliente;
  5.  
  6. class ClientePersister
  7. {
  8. /**
  9. * @var \PDO
  10. */
  11. protected $pdo;
  12.  
  13. protected $clientes = array();
  14.  
  15. public function __construct(\PDO $pdo)
  16. {
  17. $this->pdo = $pdo;
  18. }
  19.  
  20. public function persist(Cliente $cliente)
  21. {
  22. $this->clientes[] = $cliente;
  23. }
  24.  
  25. public function flush()
  26. {
  27. foreach ($this->clientes as $cliente) {
  28. // sua lógica para gravar os clientes no banco de dados
  29. $this->pdo->prepare("INSERT ...etc...");
  30. // ...etc...
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement