2011-09-17 23:46:24 -05:00
|
|
|
<?php namespace Laravel\Database\Connectors; use PDO;
|
|
|
|
|
|
|
|
|
|
class SQLite extends Connector {
|
|
|
|
|
|
2011-10-20 22:17:40 -05:00
|
|
|
/**
|
2012-01-16 13:59:24 -06:00
|
|
|
* Establish a PDO database connection.
|
2011-09-17 23:46:24 -05:00
|
|
|
*
|
|
|
|
|
* @param array $config
|
|
|
|
|
* @return PDO
|
|
|
|
|
*/
|
|
|
|
|
public function connect($config)
|
|
|
|
|
{
|
|
|
|
|
$options = $this->options($config);
|
|
|
|
|
|
2012-03-17 16:12:26 -05:00
|
|
|
// SQLite provides supported for "in-memory" databases, which exist only for
|
|
|
|
|
// lifetime of the request. Any given in-memory database may only have one
|
|
|
|
|
// PDO connection open to it at a time. These are mainly for tests.
|
2011-09-17 23:46:24 -05:00
|
|
|
if ($config['database'] == ':memory:')
|
|
|
|
|
{
|
|
|
|
|
return new PDO('sqlite::memory:', null, null, $options);
|
|
|
|
|
}
|
2011-09-28 22:49:20 -05:00
|
|
|
|
2012-03-27 10:25:42 -05:00
|
|
|
$path = path('storage').'database'.DS.$config['database'].'.sqlite';
|
2011-09-17 23:46:24 -05:00
|
|
|
|
2012-01-21 10:39:54 -06:00
|
|
|
return new PDO('sqlite:'.$path, null, null, $options);
|
2011-09-17 23:46:24 -05:00
|
|
|
}
|
|
|
|
|
|
2011-11-15 12:35:04 +00:00
|
|
|
}
|