1 | <?php |
||
11 | trait OrmConnection |
||
12 | { |
||
13 | /** |
||
14 | * Include logging facility |
||
15 | */ |
||
16 | use \Generics\Logger\LoggerTrait; |
||
17 | |||
18 | /** |
||
19 | * The database connection |
||
20 | * |
||
21 | * @var \PDO |
||
22 | */ |
||
23 | private $connection = null; |
||
24 | |||
25 | /** |
||
26 | * The concrete database type |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $type = null; |
||
31 | |||
32 | /** |
||
33 | * The database schema |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | private $schema = null; |
||
38 | |||
39 | /** |
||
40 | * Database connection user |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | private $user = null; |
||
45 | |||
46 | /** |
||
47 | * Database connection password |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | private $password = null; |
||
52 | |||
53 | /** |
||
54 | * Database connection host |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | private $host = null; |
||
59 | |||
60 | /** |
||
61 | * Database connection port |
||
62 | * |
||
63 | * @var int |
||
64 | */ |
||
65 | private $port = null; |
||
66 | |||
67 | /** |
||
68 | * Embedded database file |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | private $file = null; |
||
73 | |||
74 | /** |
||
75 | * Settings to use for connection |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | private $settings = null; |
||
80 | |||
81 | /** |
||
82 | * Database type |
||
83 | * |
||
84 | * @var \Nkey\Caribu\Type\IType |
||
85 | */ |
||
86 | private $dbType = null; |
||
87 | |||
88 | /** |
||
89 | * Configure the Orm |
||
90 | * |
||
91 | * @param array $options Various options to use for configuration. See documentation for details. |
||
92 | */ |
||
93 | 34 | public static function configure($options = array()) |
|
97 | |||
98 | /** |
||
99 | * Parse the options |
||
100 | * |
||
101 | * @param array $options The options to parse |
||
102 | */ |
||
103 | 34 | private static function parseOptions($options) |
|
140 | |||
141 | /** |
||
142 | * Retrieve the database type |
||
143 | * |
||
144 | * @return \Nkey\Caribu\Type\IType |
||
145 | */ |
||
146 | 34 | public function getDbType() |
|
153 | |||
154 | /** |
||
155 | * Create a new database connection |
||
156 | * |
||
157 | * @throws OrmException |
||
158 | */ |
||
159 | 33 | private function createConnection() |
|
178 | |||
179 | /** |
||
180 | * Retrieve the database connection |
||
181 | * |
||
182 | * @return \PDO The database connection |
||
183 | * |
||
184 | * @throws OrmException |
||
185 | */ |
||
186 | 34 | public function getConnection() |
|
194 | |||
195 | /** |
||
196 | * Retrieve the selected schema of the connection |
||
197 | * |
||
198 | * @return string The name of schema |
||
199 | */ |
||
200 | 6 | public function getSchema() |
|
204 | |||
205 | /** |
||
206 | * Retrieve the type of database |
||
207 | * |
||
208 | * @return string The type of database |
||
209 | */ |
||
210 | 34 | public function getType() |
|
214 | |||
215 | /** |
||
216 | * Detach connection |
||
217 | */ |
||
218 | 33 | private function passivateConnection() |
|
222 | } |
||
223 |