summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/sql/src/Adapter/Oracle.php
blob: de0aee5fc00f8b2ccf580e9ad7afaa07203505ec (plain)
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
<?php

namespace ipl\Sql\Adapter;

use ipl\Sql\Config;
use ipl\Sql\Connection;

class Oracle extends BaseAdapter
{
    public function getDsn(Config $config)
    {
        $dsn = 'oci:dbname=';

        if (! empty($config->host)) {
            $dsn .= "//{$config->host}";

            if (! empty($config->port)) {
                $dsn .= ":{$config->port}/";
            }

            $dsn .= '/';
        }

        $dsn .= $config->dbname;

        if (! empty($config->charset)) {
            $dsn .= ";charset={$config->charset}";
        }

        return $dsn;
    }

    public function setClientTimezone(Connection $db)
    {
        $db->prepexec('ALTER SESSION SET TIME_ZONE = ?', [$this->getTimezoneOffset()]);

        return $this;
    }
}