Adapter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDbDump/ for the canonical source repository
6
 * @copyright   Copyright (c) 2014-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDbDump\Db\Dump;
12
13
use WebinoDbDump\Exception;
14
use Zend\Db\Adapter\Adapter as DbAdapter;
15
use Zend\Db\Adapter\AdapterInterface as DbAdapterInterface;
16
17
/**
18
 * Database dump utility adapter
19
 */
20
class Adapter
21
{
22
    /**
23
     * @var DbAdapterInterface
24
     */
25
    protected $adapter;
26
27
    /**
28
     * @param DbAdapterInterface $adapter
29
     */
30
    public function __construct(DbAdapterInterface $adapter)
31
    {
32
        $this->adapter = $adapter;
33
    }
34
35
    /**
36
     * @return \Zend\Db\Adapter\Platform\PlatformInterface
37
     */
38
    public function getPlatform()
39
    {
40
        return $this->adapter->getPlatform();
41
    }
42
43
    /**
44
     * Returns database name
45
     *
46
     * @return string
47
     */
48
    public function getSchema()
49
    {
50
        return $this->adapter->getDriver()->getConnection()->getCurrentSchema();
51
    }
52
53
    /**
54
     * @param string $sql
55
     * @return \Zend\Db\ResultSet\ResultSet
56
     * @throws Exception\SqlQueryException
57
     */
58
    public function executeQuery($sql)
59
    {
60
        try {
61
            return $this->adapter->query($sql, DbAdapter::QUERY_MODE_EXECUTE);
62
        } catch (\Exception $exc) {
63
            throw new Exception\SqlQueryException(
64
                PHP_EOL . $exc->getMessage() . PHP_EOL . $sql . PHP_EOL
65
            );
66
        }
67
    }
68
}
69