PgConnection::runQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace crojasaragonez\UtnDb;
6
7
class PgConnection extends DbConnection
8
{
9
    private $connection;
10
    public function __construct($user, $password, $database, $port, $server)
11
    {
12
        parent::__construct($user, $password, $database, $port, $server);
13
    }
14
15
    public function connect()
16
    {
17
        $this->connection = pg_connect("host=$this->server port=$this->port dbname=$this->database user=$this->user password=$this->password");
18
    }
19
20
    public function disconnect()
21
    {
22
        pg_close($this->connection);
23
    }
24
25
    public function runQuery($sql, $params = [])
26
    {
27
        return pg_fetch_all($this->runStatement($sql, $params));
28
    }
29
30
    public function runStatement($sql, $params = [])
31
    {
32
        return pg_query_params($this->connection, $sql, $params);
33
    }
34
}