sqlite.php 734 B

12345678910111213141516171819202122232425262728
  1. <?php namespace Laravel\Database\Connectors; use PDO;
  2. class SQLite extends Connector {
  3. /**
  4. * Establish a PDO database connection.
  5. *
  6. * @param array $config
  7. * @return PDO
  8. */
  9. public function connect($config)
  10. {
  11. $options = $this->options($config);
  12. // SQLite provides supported for "in-memory" databases, which exist only for
  13. // lifetime of the request. Any given in-memory database may only have one
  14. // PDO connection open to it at a time. These are mainly for tests.
  15. if ($config['database'] == ':memory:')
  16. {
  17. return new PDO('sqlite::memory:', null, null, $options);
  18. }
  19. $path = path('storage').'database'.DS.$config['database'].'.sqlite';
  20. return new PDO('sqlite:'.$path, null, null, $options);
  21. }
  22. }