1 | <?php |
||
20 | class GenericConnectionManager implements ConnectionManager { |
||
21 | |||
22 | /** |
||
23 | * Array of database connections |
||
24 | * @var [] |
||
25 | */ |
||
26 | protected $connections = []; |
||
27 | |||
28 | /** |
||
29 | * Name of the default connection. |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $default = ''; |
||
33 | |||
34 | public function add( $name, $connection ) { |
||
50 | |||
51 | public function remove( $name ) { |
||
55 | |||
56 | public function get( $name ) { |
||
59 | |||
60 | public function has( $name ) { |
||
63 | |||
64 | public function getDefault() { |
||
67 | |||
68 | public function setDefault( $name ) { |
||
78 | |||
79 | /** |
||
80 | * Create a suitable implementation of DatabaseConnection based on the specified DSN. |
||
81 | * @param mixed $dsn |
||
82 | * @return DatabaseConnection |
||
83 | */ |
||
84 | protected function create( $dsn ) { |
||
102 | |||
103 | /** |
||
104 | * Ensure we have a valid DSN instance. |
||
105 | * @param mixed $dsn a string, array or DSN instance |
||
106 | * @return DSN |
||
107 | */ |
||
108 | protected function validateDSN( $dsn ) { |
||
118 | |||
119 | /** |
||
120 | * Create a MySQL connection. |
||
121 | * @param DSN $dsn |
||
122 | * @return adapters\MySQLConnection |
||
123 | */ |
||
124 | protected function createMySQL( DSN $dsn ) { |
||
127 | |||
128 | /** |
||
129 | * Create a PgSQL connection. |
||
130 | * @param DSN $dsn |
||
131 | * @return adapters\PgSQLConnection |
||
132 | */ |
||
133 | protected function createPgSQL( DSN $dsn ) { |
||
136 | |||
137 | /** |
||
138 | * Create a SQLite connection. |
||
139 | * @param DSN $dsn |
||
140 | * @return adapters\SQLiteConnection |
||
141 | */ |
||
142 | protected function createSQLite( DSN $dsn ) { |
||
145 | |||
146 | /** |
||
147 | * Ensure we have a valid connection name, i.e. it's not empty and doesn't already exist. |
||
148 | * @param string $name |
||
149 | * @return void |
||
150 | */ |
||
151 | protected function checkName( $name ) { |
||
157 | |||
158 | } |
||
159 | |||
160 | // EOF |