1 | <?php |
||
13 | class Describe |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $columns = []; |
||
19 | |||
20 | /** |
||
21 | * @var \Rougin\Describe\Driver\DriverInterface |
||
22 | */ |
||
23 | protected $driver; |
||
24 | |||
25 | /** |
||
26 | * @param \Rougin\Describe\Driver\DriverInterface $driver |
||
27 | */ |
||
28 | 78 | public function __construct(\Rougin\Describe\Driver\DriverInterface $driver) |
|
32 | |||
33 | /** |
||
34 | * Gets the primary key in the specified table. |
||
35 | * |
||
36 | * @param string $tableName |
||
37 | * @return string |
||
38 | */ |
||
39 | 12 | public function getPrimaryKey($tableName) |
|
55 | |||
56 | /** |
||
57 | * Returns the result. |
||
58 | * |
||
59 | * @param string $tableName |
||
60 | * @return array |
||
61 | * @throws \Rougin\Describe\Exceptions\TableNameNotFoundException |
||
62 | */ |
||
63 | 54 | public function getTable($tableName) |
|
64 | 3 | { |
|
65 | 54 | $table = $this->driver->getTable($tableName); |
|
66 | |||
67 | 54 | if (empty($table) || is_null($table)) { |
|
68 | 6 | $message = '"' . $tableName . '" table not found in database!'; |
|
69 | |||
70 | 6 | throw new Exceptions\TableNameNotFoundException($message); |
|
71 | } |
||
72 | |||
73 | 48 | return $table; |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * Shows the list of tables. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | 12 | public function showTables() |
|
85 | |||
86 | /** |
||
87 | * Calls methods from this class in underscore case. |
||
88 | * |
||
89 | * @param string $method |
||
90 | * @param mixed $parameters |
||
91 | * @return mixed |
||
92 | */ |
||
93 | public function __call($method, $parameters) |
||
97 | } |
||
98 |