Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit f0040df

Browse files
committed
Updated to version 1.1.3
1 parent bdcc307 commit f0040df

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

README-ES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ $db = Database::getConnection(
101101
'password', # Contraseña de la base de datos
102102
array('charset' => 'utf8')
103103
);
104+
105+
// Y una vez establecida la conexión:
106+
107+
$db = Database::getConnection('identifier');
104108
```
109+
105110
### Select
106111

107112
Seleccionar en la base de datos.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ $db = Database::getConnection(
101101
'password', # Database password
102102
array('charset' => 'utf8')
103103
);
104+
105+
// And once the connection is established:
106+
107+
$db = Database::getConnection('identifier');
104108
```
105109

106110
### Select

src/Database.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@
1919
*/
2020
class Database {
2121

22-
/**
23-
* Identifying name for the database.
24-
*
25-
* @since 1.1.3
26-
*
27-
* @var object
28-
*/
29-
public static $id = null;
30-
3122
/**
3223
* Database provider.
3324
*
@@ -277,28 +268,26 @@ private function __construct($provider, $host, $dbUser, $dbName, $pass, $setting
277268
*
278269
* @return object → object with the connection
279270
*/
280-
public static function getConnection($databaseID, $provider, $host, $dbUser, $dbName, $pass, $settings) {
271+
public static function getConnection($databaseID, $provider = null, $host = null, $dbUser = null, $dbName = null, $pass = null, $settings = null) {
281272

282-
if (self::$id !== $databaseID) {
273+
if (isset(self::$_conn[$databaseID])) {
283274

284-
self::$_conn[self::$id] = false;
275+
return self::$_conn[$databaseID];
285276
}
286277

287-
self::$id = $databaseID;
288-
289-
if (!self::$_conn[self::$id]) {
278+
if (!self::$_conn[$databaseID]) {
290279

291-
self::$_conn[self::$id] = new Database(
280+
self::$_conn[$databaseID] = new Database(
292281
$provider,
293282
$host,
294283
$dbUser,
295284
$dbName,
296285
$pass,
297286
$settings
298287
);
299-
}
300-
301-
return self::$_conn[self::$id];
288+
}
289+
290+
return self::$_conn[$databaseID];
302291
}
303292

304293
/**

0 commit comments

Comments
 (0)