Inheritance: extends Pimple\Container
Beispiel #1
0
 public function __construct(PDO $conn, BaseBuilder $builder, Logger $logger = NULL)
 {
     $this->conn = $conn;
     $this->builder = $builder;
     $c = ServiceContainer::getInstance();
     $this->logger = $logger ?: $c['logger'];
 }
 public function execute()
 {
     $dsId = $this->getCurrentDataSourceId();
     $container = ServiceContainer::getInstance();
     $runner = new MigrationRunner($dsId);
     $runner->runUpgradeAutomatically($this->options);
     $this->logger->info('Done.');
 }
Beispiel #3
0
 public function __construct(BaseDriver $driver, PDO $connection)
 {
     $c = ServiceContainer::getInstance();
     $this->driver = $driver;
     $this->connection = $connection;
     $this->logger = $c['logger'] ?: Console::getInstance()->getLogger();
     $this->builder = SqlBuilder::create($driver);
 }
 public function __construct($dsIds)
 {
     $c = ServiceContainer::getInstance();
     $this->logger = $c['logger'];
     $this->connectionManager = ConnectionManager::getInstance();
     // XXX: get data source id list from config loader
     $this->dataSourceIds = (array) $dsIds;
 }
Beispiel #5
0
 public function __construct(array $paths = array(), Logger $logger = null)
 {
     $this->paths = $paths;
     if (!$logger) {
         $c = ServiceContainer::getInstance();
         $logger = $c['logger'];
     }
     $this->logger = $logger;
 }
 public function __construct(BaseDriver $driver, PDO $connection)
 {
     $this->driver = $driver;
     $this->connection = $connection;
     $c = ServiceContainer::getInstance();
     $this->config = $c['config_loader'];
     // pre-initialize all schema objects and expand template schema
     $this->schemas = SchemaUtils::findSchemasByConfigLoader($this->config, $c['logger']);
     $this->schemas = SchemaUtils::filterBuildableSchemas($this->schemas);
     // map table names to declare schema objects
     foreach ($this->schemas as $schema) {
         $this->schemaMap[$schema->getTable()] = $schema;
     }
 }
Beispiel #7
0
 public function __construct(Connection $conn, BaseBuilder $builder = null, Logger $logger = null)
 {
     $this->conn = $conn;
     $this->queryDriver = $conn->createQueryDriver();
     if (!$builder) {
         $builder = SqlBuilder::create($this->queryDriver);
     }
     $this->builder = $builder;
     if (!$logger) {
         $c = ServiceContainer::getInstance();
         $logger ?: $c['logger'];
     }
     $this->logger = $logger;
 }
 public static function show(PDOException $e, $sqlQuery = null, array $arguments = null, Logger $logger = null)
 {
     $c = ServiceContainer::getInstance();
     $logger = $logger ?: $c['logger'];
     $logger->error('Exception: ' . get_class($e));
     $logger->error('Error Message: ' . $e->getMessage());
     if ($sqlQuery) {
         $logger->error('Query: ' . $sqlQuery);
     } else {
         $logger->error('Query: Not Supplied.');
     }
     if ($arguments) {
         $logger->error('Arguments: ' . var_export($arguments, true));
     }
     if ($e->errorInfo) {
         $logger->error('Error Info: ' . var_export($e->errorInfo, true));
     }
     $logger->error("File: {$e->getFile()} @ {$e->getLine()}");
 }
 public function execute()
 {
     $dsId = $this->getCurrentDataSourceId();
     $container = ServiceContainer::getInstance();
     $conn = $this->getCurrentConnection();
     $driver = $this->getCurrentQueryDriver();
     if ($this->options->backup) {
         if (!$driver instanceof PDOMySQLDriver) {
             $this->logger->error('backup is only supported for MySQL');
             return false;
         }
         $this->logger->info('Backing up database...');
         $backup = new MySQLBackup();
         if ($dbname = $backup->incrementalBackup($conn)) {
             $this->logger->info("Backup at {$dbname}");
         }
     }
     $runner = new MigrationRunner($this->logger, $dsId);
     $this->logger->info("Performing automatic upgrade over data source: {$dsId}");
     $tableSchemas = SchemaLoader::loadSchemaTableMap();
     $runner->runUpgradeAutomatically($conn, $driver, $tableSchemas, $this->options);
     $this->logger->info('Done.');
 }