Esempio n. 1
0
 /**
  * Counts the number of objects to dump, including the table rows.
  *
  * @param callable $output A function that will be called for every count.
  *
  * @return void
  */
 public function countObjects(callable $output)
 {
     $output(count($this->driver->getPreDumpSql()));
     foreach (self::OBJECT_TYPES as $objectType) {
         $objects = $this->driver->getObjects($objectType);
         $output(count($objects));
         if ($objectType == self::OBJECT_TABLE) {
             foreach ($objects as $tableName) {
                 $tableName = $this->driver->quoteIdentifier($tableName);
                 $rows = $this->pdo->query("SELECT COUNT(*) FROM {$tableName}")->fetchColumn();
                 $output($rows);
             }
         }
     }
     $output(count($this->driver->getPostDumpSql()));
 }
Esempio n. 2
0
 /**
  * @param Driver $driver  The target driver.
  * @param int    $version The version being applied.
  *
  * @return void
  *
  * @throws \RuntimeException
  */
 private function endUpdate(Driver $driver, int $version)
 {
     $pdo = $driver->getPdo();
     $table = $driver->quoteIdentifier($this->configuration->getVersionTableName());
     $statement = $pdo->prepare("UPDATE {$table} SET upgradeEnd = CURRENT_TIMESTAMP() WHERE version = ?");
     $statement->execute([$version]);
     if ($statement->rowCount() != 1) {
         throw new \RuntimeException('Unexpected number of affected rows');
     }
 }