1 | <?php |
||
17 | class MySQLDriver extends AbstractDriver implements DriverInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $database; |
||
23 | |||
24 | /** |
||
25 | * @var \PDO |
||
26 | */ |
||
27 | protected $pdo; |
||
28 | |||
29 | /** |
||
30 | * Initializes the driver instance. |
||
31 | * |
||
32 | * @param \PDO $pdo |
||
33 | * @param string $database |
||
34 | */ |
||
35 | 105 | public function __construct(\PDO $pdo, $database) |
|
43 | |||
44 | /** |
||
45 | * Returns an array of Column instances from a table. |
||
46 | * |
||
47 | * @param string $table |
||
48 | * @return \Rougin\Describe\Column[] |
||
49 | */ |
||
50 | 84 | public function columns($table) |
|
54 | |||
55 | /** |
||
56 | * Returns an array of Column instances from a table. |
||
57 | * NOTE: To be removed in v2.0.0. Use columns() instead. |
||
58 | * |
||
59 | * @param string $table |
||
60 | * @return \Rougin\Describe\Column[] |
||
61 | */ |
||
62 | 48 | public function getColumns($table) |
|
66 | |||
67 | /** |
||
68 | * Returns an array of Column instances from a table. |
||
69 | * NOTE: To be removed in v2.0.0. Use getColumns() instead. |
||
70 | * |
||
71 | * @param string $table |
||
72 | * @return \Rougin\Describe\Column[] |
||
73 | */ |
||
74 | 42 | public function getTable($table) |
|
78 | |||
79 | /** |
||
80 | * Returns an array of table names. |
||
81 | * NOTE: To be removed in v2.0.0. Use tables() instead. |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 6 | public function getTableNames() |
|
89 | |||
90 | /** |
||
91 | * Returns an array of table names. |
||
92 | * NOTE: To be removed in v2.0.0. Use getTableNames() instead. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | 3 | public function showTables() |
|
100 | |||
101 | /** |
||
102 | * Returns an array of Table instances. |
||
103 | * |
||
104 | * @return \Rougin\Describe\Table[] |
||
105 | */ |
||
106 | 12 | public function tables() |
|
110 | |||
111 | /** |
||
112 | * Prepares the defined columns. |
||
113 | * |
||
114 | * @param \Rougin\Describe\Column $column |
||
115 | * @param string $table |
||
116 | * @param mixed $row |
||
117 | * @return \Rougin\Describe\Column |
||
118 | */ |
||
119 | 78 | protected function column(Column $column, $table, $row) |
|
141 | |||
142 | /** |
||
143 | * Sets the properties of a column if it does exists. |
||
144 | * |
||
145 | * @param string $name |
||
146 | * @param mixed $row |
||
147 | * @param \Rougin\Describe\Column $column |
||
148 | * @return \Rougin\Describe\Column |
||
149 | */ |
||
150 | 78 | protected function foreign($name, $row, Column $column) |
|
175 | |||
176 | /** |
||
177 | * Returns an array of table names or Table instances. |
||
178 | * NOTE: To be removed in v2.0.0. Move to tables() instead. |
||
179 | * |
||
180 | * @param boolean $instance |
||
181 | * @param array $tables |
||
182 | * @return array|\Rougin\Describe\Table[] |
||
183 | */ |
||
184 | 18 | protected function items($instance = false, $tables = array()) |
|
199 | |||
200 | /** |
||
201 | * Sets the key of a column. |
||
202 | * |
||
203 | * @param mixed $row |
||
204 | * @param \Rougin\Describe\Column $column |
||
205 | * @return \Rougin\Describe\Column |
||
206 | */ |
||
207 | 78 | protected function keys($row, Column $column) |
|
228 | |||
229 | /** |
||
230 | * Sets the properties of a column. |
||
231 | * |
||
232 | * @param mixed $row |
||
233 | * @param \Rougin\Describe\Column $column |
||
234 | * @return \Rougin\Describe\Column |
||
235 | */ |
||
236 | 78 | protected function properties($row, Column $column) |
|
246 | |||
247 | /** |
||
248 | * Strips the table schema from the table name. |
||
249 | * |
||
250 | * @param string $table |
||
251 | * @return string |
||
252 | */ |
||
253 | 78 | protected function strip($table) |
|
261 | } |
||
262 |