AbstractSchemaSynchronizer.php 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Doctrine\DBAL\Schema\Synchronizer;
  3. use Doctrine\DBAL\Connection;
  4. use Throwable;
  5. /**
  6. * Abstract schema synchronizer with methods for executing batches of SQL.
  7. */
  8. abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
  9. {
  10. /** @var Connection */
  11. protected $conn;
  12. public function __construct(Connection $conn)
  13. {
  14. $this->conn = $conn;
  15. }
  16. /**
  17. * @param string[] $sql
  18. */
  19. protected function processSqlSafely(array $sql)
  20. {
  21. foreach ($sql as $s) {
  22. try {
  23. $this->conn->exec($s);
  24. } catch (Throwable $e) {
  25. }
  26. }
  27. }
  28. /**
  29. * @param string[] $sql
  30. */
  31. protected function processSql(array $sql)
  32. {
  33. foreach ($sql as $s) {
  34. $this->conn->exec($s);
  35. }
  36. }
  37. }