Test Setup Failed
Push — master ( d6fde7...1e848b )
by Php Easy Api
04:20
created

QueryStack::showColumnsFrom()   A

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 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Migratio\GrammarStructure\Mysql\Traits;
4
5
trait QueryStack
6
{
7
    /**
8
     * @return mixed
9
     */
10
    public function connection()
11
    {
12
        return $this->schema->getConnection();
13
    }
14
15
    /**
16
     * @return mixed
17
     */
18
    public function showTables()
19
    {
20
       return $this->connection()->query('SHOW TABLES')->fetchAll();
21
    }
22
23
    /**
24
     * @param $table
25
     * @return mixed
26
     */
27
    public function showColumnsFrom($table)
28
    {
29
        return $this->connection()->query('SHOW COLUMNS FROM '.$table)->fetchAll();
30
    }
31
32
    /**
33
     * @param $query
34
     * @return mixed
35
     */
36
    public function setQueryBasic($query)
37
    {
38
        try {
39
40
            $query =$this->connection()->query($query);
41
42
            return [
43
                'result'=>true,
44
                'query'=>$query,
45
                'message'=>null,
46
            ];
47
        }
48
        catch (\PDOException $exception){
49
50
            return [
51
                'result'=>false,
52
                'query'=>$query,
53
                'message'=>$exception->getMessage(),
54
            ];
55
        }
56
57
    }
58
59
}
60
61