Completed
Pull Request — master (#4)
by Rougin
03:41
created

AbstractDriver::getQuery()   A

Complexity

Conditions 3
Paths 8

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 8
nc 8
nop 2
crap 3
1
<?php
2
3
namespace Rougin\Describe\Driver;
4
5
/**
6
 * Abstract Driver
7
 *
8
 * @package  Describe
9
 * @category Driver
10
 * @author   Rougin Royce Gutib <[email protected]>
11
 */
12
abstract class AbstractDriver
13
{
14
    /**
15
     * @var \PDO
16
     */
17
    protected $pdo;
18
19
    /**
20
     * Returns the list of columns based on the specified query.
21
     *
22
     * @param  string $tableName
23
     * @param  string $query
24
     * @return void
25
     */
26 66
    public function getQuery($tableName, $query)
27
    {
28
        try {
29 66
            $information = $this->pdo->prepare($query);
30
31 66
            $information->execute();
32 66
            $information->setFetchMode(\PDO::FETCH_OBJ);
33 66
        } catch (\PDOException $e) {
34
            // Table not found
35
        }
36
37 66
        while ($row = $information->fetch()) {
38 60
            $this->setColumn($tableName, $row);
39 60
        }
40 66
    }
41
}
42