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 |
||
92 | * Various options to use for configuration. See documentation for details. |
||
93 | */ |
||
94 | 34 | public static function configure($options = array()) |
|
98 | |||
99 | /** |
||
100 | * Assign the option to local configuration |
||
101 | * |
||
102 | * @param string $option |
||
103 | * The option to assign |
||
104 | * @param mixed $value |
||
105 | * The value to assign to option |
||
106 | */ |
||
107 | 34 | private static function assignOption($option, $value) |
|
142 | |||
143 | /** |
||
144 | * Parse the options |
||
145 | * |
||
146 | * @param array $options |
||
147 | * The options to parse |
||
148 | */ |
||
149 | 34 | private static function parseOptions($options) |
|
155 | |||
156 | /** |
||
157 | * Retrieve the database type |
||
158 | * |
||
159 | * @return \Nkey\Caribu\Type\IType |
||
160 | */ |
||
161 | 34 | public function getDbType() |
|
168 | |||
169 | /** |
||
170 | * Create a new database connection |
||
171 | * |
||
172 | * @throws OrmException |
||
173 | */ |
||
174 | 33 | private function createConnection() |
|
193 | |||
194 | /** |
||
195 | * Retrieve the database connection |
||
196 | * |
||
197 | * @return \PDO The database connection |
||
198 | * |
||
199 | * @throws OrmException |
||
200 | */ |
||
201 | 34 | public function getConnection() |
|
209 | |||
210 | /** |
||
211 | * Retrieve the selected schema of the connection |
||
212 | * |
||
213 | * @return string The name of schema |
||
214 | */ |
||
215 | 6 | public function getSchema() |
|
219 | |||
220 | /** |
||
221 | * Retrieve the type of database |
||
222 | * |
||
223 | * @return string The type of database |
||
224 | */ |
||
225 | 34 | public function getType() |
|
229 | |||
230 | /** |
||
231 | * Detach connection |
||
232 | */ |
||
233 | 33 | private function passivateConnection() |
|
237 | } |
||
238 |