SQLiteBuilder.php 789 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Illuminate\Database\Schema;
  3. class SQLiteBuilder extends Builder
  4. {
  5. /**
  6. * Drop all tables from the database.
  7. *
  8. * @return void
  9. */
  10. public function dropAllTables()
  11. {
  12. if ($this->connection->getDatabaseName() !== ':memory:') {
  13. return $this->refreshDatabaseFile();
  14. }
  15. $this->connection->select($this->grammar->compileEnableWriteableSchema());
  16. $this->connection->select($this->grammar->compileDropAllTables());
  17. $this->connection->select($this->grammar->compileDisableWriteableSchema());
  18. }
  19. /**
  20. * Empty the database file.
  21. *
  22. * @return void
  23. */
  24. public function refreshDatabaseFile()
  25. {
  26. file_put_contents($this->connection->getDatabaseName(), '');
  27. }
  28. }