protected function purgeTables(array $tablesList) { $this->connection->query('SET FOREIGN_KEY_CHECKS=0;'); foreach ($tablesList as $table) { $query = $this->dbPlatform->getTruncateTableSql($table); try { $this->output->writeln('Purging data from ' . $table); $this->connection->executeUpdate($query); } catch (\Exception $e) { $this->output->writeln('Error purging data from \'' . $table . '\'. Error: ' . $e->getMessage()); $this->connection->query('SET FOREIGN_KEY_CHECKS=1;'); throw $e; } } $this->connection->query('SET FOREIGN_KEY_CHECKS=1;'); }
/** * @param AbstractPlatform $dbPlatform * @param string $tableName * @return string */ protected function getTruncateQuery(AbstractPlatform $dbPlatform, $tableName) { return $dbPlatform->getTruncateTableSql($tableName); }