1 | <?php /** DriverMicro */ |
||
19 | abstract class Driver implements IDriver |
||
20 | { |
||
21 | /** @var \PDO|null $conn Connection to DB */ |
||
22 | protected $conn; |
||
23 | |||
24 | |||
25 | /** |
||
26 | * Driver constructor. |
||
27 | * |
||
28 | * @access public |
||
29 | * |
||
30 | * @param string $dsn DSN connection string |
||
31 | * @param array $config Configuration of connection |
||
32 | * @param array $options Other options |
||
33 | * |
||
34 | * @result void |
||
35 | * @throws Exception |
||
36 | */ |
||
37 | public function __construct($dsn, array $config = [], array $options = []) |
||
49 | |||
50 | /** |
||
51 | * Get driver type of current connection |
||
52 | * |
||
53 | * @access public |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getDriverType() |
||
60 | |||
61 | /** |
||
62 | * Destructor for this class |
||
63 | * |
||
64 | * @access public |
||
65 | * @return void |
||
66 | */ |
||
67 | public function __destruct() |
||
71 | |||
72 | /** |
||
73 | * Table exists in db |
||
74 | * |
||
75 | * @access public |
||
76 | * |
||
77 | * @param string $table Table name |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function tableExists($table) |
||
85 | |||
86 | /** |
||
87 | * Remove table from database |
||
88 | * |
||
89 | * @access public |
||
90 | * |
||
91 | * @param string $name Table name |
||
92 | * |
||
93 | * @return mixed |
||
94 | */ |
||
95 | public function removeTable($name) |
||
99 | |||
100 | /** |
||
101 | * Clear all data from table |
||
102 | * |
||
103 | * @access public |
||
104 | * |
||
105 | * @param string $name Table name |
||
106 | * |
||
107 | * @return int |
||
108 | */ |
||
109 | public function clearTable($name) |
||
113 | |||
114 | /** |
||
115 | * Get info of a field |
||
116 | * |
||
117 | * @access public |
||
118 | * |
||
119 | * @param string $field Field name |
||
120 | * @param string $table Table name |
||
121 | * |
||
122 | * @return array|boolean |
||
123 | */ |
||
124 | public function fieldInfo($field, $table) |
||
132 | |||
133 | /** |
||
134 | * Field exists in table |
||
135 | * |
||
136 | * @access public |
||
137 | * |
||
138 | * @param string $field Field name |
||
139 | * @param string $table Table name |
||
140 | * |
||
141 | * @return boolean |
||
142 | */ |
||
143 | public function fieldExists($field, $table) |
||
153 | |||
154 | /** |
||
155 | * Delete row from table |
||
156 | * |
||
157 | * @access public |
||
158 | * |
||
159 | * @param string $table Table name |
||
160 | * @param string $conditions Conditions to search |
||
161 | * @param array $params Params array |
||
162 | * |
||
163 | * @return bool |
||
164 | */ |
||
165 | public function delete($table, $conditions, array $params = []) |
||
169 | |||
170 | /** |
||
171 | * Count element in sub-query |
||
172 | * |
||
173 | * @access public |
||
174 | * |
||
175 | * @param string $query Query |
||
176 | * @param string $table Table name |
||
177 | * |
||
178 | * @return integer|boolean |
||
179 | */ |
||
180 | public function count($query = '', $table = '') |
||
195 | |||
196 | /** |
||
197 | * Send RAW query to DB |
||
198 | * |
||
199 | * @access public |
||
200 | * |
||
201 | * @param string $query Raw query to db |
||
202 | * @param array $params Params for query |
||
203 | * @param int $fetchType Fetching type |
||
204 | * @param string $fetchClass Fetching class |
||
205 | * |
||
206 | * @return \PDOStatement|array |
||
207 | * @throws Exception |
||
208 | */ |
||
209 | public function rawQuery($query = '', array $params = [], $fetchType = \PDO::FETCH_ASSOC, $fetchClass = 'Model') |
||
228 | } |