Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Driver\SQLite3;
4
 
5
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
6
use Doctrine\DBAL\Driver\API\SQLite\UserDefinedFunctions;
7
use SQLite3;
8
 
9
final class Driver extends AbstractSQLiteDriver
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function connect(array $params): Connection
15
    {
16
        $isMemory = (bool) ($params['memory'] ?? false);
17
 
18
        if (isset($params['path'])) {
19
            if ($isMemory) {
20
                throw new Exception(
21
                    'Invalid connection settings: specifying both parameters "path" and "memory" is ambiguous.',
22
                );
23
            }
24
 
25
            $filename = $params['path'];
26
        } elseif ($isMemory) {
27
            $filename = ':memory:';
28
        } else {
29
            throw new Exception(
30
                'Invalid connection settings: specify either the "path" or the "memory" parameter for SQLite3.',
31
            );
32
        }
33
 
34
        try {
35
            $connection = new SQLite3($filename);
36
        } catch (\Exception $e) {
37
            throw Exception::new($e);
38
        }
39
 
40
        $connection->enableExceptions(true);
41
 
42
        UserDefinedFunctions::register([$connection, 'createFunction']);
43
 
44
        return new Connection($connection);
45
    }
46
}