Files
spa-api/laravel/database/connectors/sqlite.php

32 lines
941 B
PHP
Raw Normal View History

<?php namespace Laravel\Database\Connectors; use PDO;
class SQLite extends Connector {
/**
2012-01-16 13:59:24 -06:00
* Establish a PDO database connection.
*
* @param array $config
* @return PDO
*/
public function connect($config)
{
$options = $this->options($config);
2011-11-02 21:27:43 -05:00
// SQLite provides supported for "in-memory" databases, which exist only for the
// lifetime of the request. Any given in-memory database may only have one PDO
2012-02-13 23:51:33 -06:00
// connection open to it at a time. These are usually for testing.
if ($config['database'] == ':memory:')
{
return new PDO('sqlite::memory:', null, null, $options);
}
2011-09-28 22:49:20 -05:00
// SQLite databases will be created automatically if they do not exist, so we
// will not check for the existence of the database file before establishing
// the PDO connection to the database.
2012-01-28 14:55:08 -06:00
$path = path('storage').'database'.DS.$config['database'].'.sqlite';
return new PDO('sqlite:'.$path, null, null, $options);
}
2011-11-15 12:35:04 +00:00
}