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

QueryStack   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 49
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A showColumnsFrom() 0 3 1
A showTables() 0 3 1
A setQueryBasic() 0 18 2
A connection() 0 3 1
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