Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Seu\Namespace\;
- use Seu\Namespace\Cliente;
- class ClientePersister
- {
- /**
- * @var \PDO
- */
- protected $pdo;
- protected $clientes = array();
- public function __construct(\PDO $pdo)
- {
- $this->pdo = $pdo;
- }
- public function persist(Cliente $cliente)
- {
- $this->clientes[] = $cliente;
- }
- public function flush()
- {
- foreach ($this->clientes as $cliente) {
- // sua lógica para gravar os clientes no banco de dados
- $this->pdo->prepare("INSERT ...etc...");
- // ...etc...
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement