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