sqlite.php 734 Bytes
Newer Older
1 2 3 4 5
<?php namespace Laravel\Database\Connectors; use PDO;

class SQLite extends Connector {

	/**
6
	 * Establish a PDO database connection.
7 8 9 10 11 12 13 14
	 *
	 * @param  array  $config
	 * @return PDO
	 */
	public function connect($config)
	{
		$options = $this->options($config);

Taylor Otwell committed
15 16 17
		// 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.
18 19 20 21
		if ($config['database'] == ':memory:')
		{
			return new PDO('sqlite::memory:', null, null, $options);
		}
22

Taylor Otwell committed
23
		$path = path('storage').'database'.DS.$config['database'].'.sqlite';
24

25
		return new PDO('sqlite:'.$path, null, null, $options);
26 27
	}

Phill Sparks committed
28
}