-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathConnection.php
More file actions
82 lines (66 loc) · 2.21 KB
/
Connection.php
File metadata and controls
82 lines (66 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Pgsql;
use Yiisoft\Db\Driver\Pdo\AbstractPdoConnection;
use Yiisoft\Db\Driver\Pdo\PdoCommandInterface;
use InvalidArgumentException;
use Yiisoft\Db\Pgsql\Column\ColumnBuilder;
use Yiisoft\Db\Pgsql\Column\ColumnFactory;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;
use Yiisoft\Db\Transaction\TransactionInterface;
/**
* Implements a connection to a database via PDO (PHP Data Objects) for PostgreSQL Server.
*
* @link https://www.php.net/manual/en/ref.pdo-pgsql.php
*/
final class Connection extends AbstractPdoConnection
{
public function createCommand(?string $sql = null, array $params = []): PdoCommandInterface
{
$command = new Command($this);
if ($sql !== null) {
$command->setSql($sql);
}
if ($this->logger !== null) {
$command->setLogger($this->logger);
}
if ($this->profiler !== null) {
$command->setProfiler($this->profiler);
}
return $command->bindValues($params);
}
public function createTransaction(): TransactionInterface
{
return new Transaction($this);
}
public function getColumnBuilderClass(): string
{
return ColumnBuilder::class;
}
public function getColumnFactory(): ColumnFactoryInterface
{
return $this->columnFactory ??= new ColumnFactory();
}
public function getLastInsertId(?string $sequenceName = null): string
{
if ($sequenceName === null) {
throw new InvalidArgumentException('PostgreSQL not support lastInsertId without sequence name.');
}
return parent::getLastInsertId($sequenceName);
}
public function getQueryBuilder(): QueryBuilderInterface
{
return $this->queryBuilder ??= new QueryBuilder($this);
}
public function getQuoter(): QuoterInterface
{
return $this->quoter ??= new Quoter('"', '"', $this->getTablePrefix());
}
public function getSchema(): SchemaInterface
{
return $this->schema ??= new Schema($this, $this->schemaCache);
}
}