Conditions | 4 |
Paths | 5 |
Total Lines | 32 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 22 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | 12 | public function getTable($table) |
|
36 | { |
||
37 | 12 | $columns = []; |
|
38 | |||
39 | 12 | $information = $this->pdo->prepare( |
|
40 | 12 | 'PRAGMA table_info("' . $table . '");' |
|
41 | 12 | ); |
|
42 | |||
43 | 12 | $information->execute(); |
|
44 | 12 | $information->setFetchMode(PDO::FETCH_OBJ); |
|
45 | |||
46 | 12 | while ($row = $information->fetch()) { |
|
47 | 12 | $column = new Column; |
|
48 | |||
49 | 12 | if ( ! $row->notnull) { |
|
50 | 12 | $column->setNull(TRUE); |
|
51 | 12 | } |
|
52 | |||
53 | 12 | if ($row->pk) { |
|
54 | 12 | $column->setPrimary(TRUE); |
|
55 | 12 | $column->setAutoIncrement(TRUE); |
|
56 | 12 | } |
|
57 | |||
58 | 12 | $column->setDefaultValue($row->dflt_value); |
|
59 | 12 | $column->setField($row->name); |
|
60 | 12 | $column->setDataType(strtolower($row->type)); |
|
61 | |||
62 | 12 | array_push($columns, $column); |
|
63 | 12 | } |
|
64 | |||
65 | 12 | return $columns; |
|
66 | } |
||
67 | |||
78 |