AbstractSchemaSynchronizer.php 835 Bytes
Newer Older
1 2 3 4 5
<?php

namespace Doctrine\DBAL\Schema\Synchronizer;

use Doctrine\DBAL\Connection;
6
use Throwable;
7 8 9 10 11 12

/**
 * Abstract schema synchronizer with methods for executing batches of SQL.
 */
abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
{
13
    /** @var Connection */
14 15 16 17 18 19 20
    protected $conn;

    public function __construct(Connection $conn)
    {
        $this->conn = $conn;
    }

Benjamin Morel's avatar
Benjamin Morel committed
21
    /**
22
     * @param string[] $sql
Benjamin Morel's avatar
Benjamin Morel committed
23
     */
24 25 26 27 28
    protected function processSqlSafely(array $sql)
    {
        foreach ($sql as $s) {
            try {
                $this->conn->exec($s);
29
            } catch (Throwable $e) {
30 31 32 33
            }
        }
    }

Benjamin Morel's avatar
Benjamin Morel committed
34
    /**
35
     * @param string[] $sql
Benjamin Morel's avatar
Benjamin Morel committed
36
     */
37 38 39 40 41 42 43
    protected function processSql(array $sql)
    {
        foreach ($sql as $s) {
            $this->conn->exec($s);
        }
    }
}