AbstractSchemaSynchronizer.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Doctrine\DBAL\Schema\Synchronizer;
  3. use Doctrine\DBAL\Connection;
  4. use Doctrine\Deprecations\Deprecation;
  5. use Throwable;
  6. /**
  7. * Abstract schema synchronizer with methods for executing batches of SQL.
  8. *
  9. * @deprecated
  10. */
  11. abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
  12. {
  13. /** @var Connection */
  14. protected $conn;
  15. public function __construct(Connection $conn)
  16. {
  17. $this->conn = $conn;
  18. Deprecation::trigger(
  19. 'doctrine/dbal',
  20. 'https://github.com/doctrine/dbal/pull/4213',
  21. 'SchemaSynchronizer API is deprecated without a replacement and will be removed in DBAL 3.0'
  22. );
  23. }
  24. /**
  25. * @param string[] $sql
  26. *
  27. * @return void
  28. */
  29. protected function processSqlSafely(array $sql)
  30. {
  31. foreach ($sql as $s) {
  32. try {
  33. $this->conn->exec($s);
  34. } catch (Throwable $e) {
  35. }
  36. }
  37. }
  38. /**
  39. * @param string[] $sql
  40. *
  41. * @return void
  42. */
  43. protected function processSql(array $sql)
  44. {
  45. foreach ($sql as $s) {
  46. $this->conn->exec($s);
  47. }
  48. }
  49. }