Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Connectors;
4
 
5
use Illuminate\Database\SQLiteDatabaseDoesNotExistException;
6
 
7
class SQLiteConnector extends Connector implements ConnectorInterface
8
{
9
    /**
10
     * Establish a database connection.
11
     *
12
     * @param  array  $config
13
     * @return \PDO
14
     *
15
     * @throws \Illuminate\Database\SQLiteDatabaseDoesNotExistException
16
     */
17
    public function connect(array $config)
18
    {
19
        $options = $this->getOptions($config);
20
 
21
        // SQLite supports "in-memory" databases that only last as long as the owning
22
        // connection does. These are useful for tests or for short lifetime store
23
        // querying. In-memory databases may only have a single open connection.
24
        if ($config['database'] === ':memory:') {
25
            return $this->createConnection('sqlite::memory:', $config, $options);
26
        }
27
 
28
        $path = realpath($config['database']);
29
 
30
        // Here we'll verify that the SQLite database exists before going any further
31
        // as the developer probably wants to know if the database exists and this
32
        // SQLite driver will not throw any exception if it does not by default.
33
        if ($path === false) {
34
            throw new SQLiteDatabaseDoesNotExistException($config['database']);
35
        }
36
 
37
        return $this->createConnection("sqlite:{$path}", $config, $options);
38
    }
39
}