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

Commit b8c04a0

Browse files
committed
Updated to 1.1.4 version
1 parent 040d573 commit b8c04a0

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# CHANGELOG
22

3+
## 1.1.4 - 2017-05-16
4+
5+
* Added `Eliasis\Model\Model->_getDatabaseInstance` method.
6+
7+
* Added compatibility with Eliasis Framework library inside getConnection method. If it exists, it will get the connection to the database.
8+
9+
* Will get the connection parameters from Eliasis Framework configuration files. It should have the following structure:
10+
11+
'db' => [
12+
13+
'identifier' => [
14+
'id' => 'identifier',
15+
'prefix' => 'identifier_',
16+
'provider' => 'PDOprovider',
17+
'host' => 'localhost',
18+
'user' => 'db_user',
19+
'name' => 'db_name',
20+
'password' => 'db_password',
21+
'settings' => ['charset' => 'utf8'],
22+
],
23+
]
24+
25+
* Eliasis Framework url: https://github.com/Eliasis-Framework/Eliasis
26+
327
## 1.1.3 - 2017-05-14
428
* Singleton pattern was added to create a single connection per database.
529

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "josantonius/database",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"type": "library",
55
"description": "Library for SQL database management to be used by several providers at the same time.",
66
"keywords": [

src/Database.php

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,17 @@ class Database {
215215
*
216216
* @param string $provider → name of provider class
217217
* @param string $host → database host
218-
* @param string $dbUser → database user
219-
* @param string $dbName → database name
220-
* @param string $pass → database password
218+
* @param string $user → database user
219+
* @param string $name → database name
220+
* @param string $password → database password
221221
* @param array $settings → database options
222222
* @param array $settings['port'] → database port
223223
* @param array $settings['charset'] → database charset
224224
*
225225
* @throws DBException → if the provider class specified does not exist
226226
* @throws DBException → if could not connect to provider
227227
*/
228-
private function __construct($provider, $host, $dbUser, $dbName, $pass, $settings) {
228+
private function __construct($provider, $host, $user, $name, $password, $settings) {
229229

230230
$providerClass = 'Josantonius\\Database\\Provider\\' . $provider;
231231

@@ -238,7 +238,7 @@ private function __construct($provider, $host, $dbUser, $dbName, $pass, $setting
238238

239239
$this->_provider = new $providerClass;
240240

241-
$this->_provider->connect($host, $dbUser, $dbName, $pass, $settings);
241+
$this->_provider->connect($host, $user, $name, $password, $settings);
242242

243243
if (!$this->_provider->isConnected()) {
244244

@@ -256,35 +256,45 @@ private function __construct($provider, $host, $dbUser, $dbName, $pass, $setting
256256
*
257257
* @since 1.0.0
258258
*
259-
* @param string $databaseID → identifying name for the database
259+
* @param string $id → identifying name for the database
260260
* @param string $provider → name of provider class
261261
* @param string $host → database host
262-
* @param string $dbUser → database user
263-
* @param string $dbName → database name
264-
* @param string $pass → database password
262+
* @param string $user → database user
263+
* @param string $name → database name
264+
* @param string $password → database password
265265
* @param array $settings → database options
266266
* @param array $settings['port'] → database port
267267
* @param array $settings['charset'] → database charset
268268
*
269269
* @return object → object with the connection
270270
*/
271-
public static function getConnection($databaseID, $provider = null, $host = null, $dbUser = null, $dbName = null, $pass = null, $settings = null) {
271+
public static function getConnection($id, $provider = null, $host = null, $user = null, $name = null, $password = null, $settings = null) {
272272

273-
if (isset(self::$_conn[$databaseID])) {
273+
if (isset(self::$_conn[$id])) {
274274

275-
return self::$_conn[$databaseID];
275+
return self::$_conn[$id];
276276
}
277277

278-
self::$_conn[$databaseID] = new Database(
278+
if (class_exists($App = 'Eliasis\\App\\App')) {
279+
280+
$provider = $provider ? $provider : $App::db($id, 'provider');
281+
$host = $host ? $host : $App::db($id, 'host');
282+
$user = $user ? $user : $App::db($id, 'user');
283+
$name = $name ? $name : $App::db($id, 'name');
284+
$password = $password ? $password : $App::db($id, 'password');
285+
$settings = $settings ? $settings : $App::db($id, 'settings');
286+
}
287+
288+
self::$_conn[$id] = new Database(
279289
$provider,
280290
$host,
281-
$dbUser,
282-
$dbName,
283-
$pass,
291+
$user,
292+
$name,
293+
$password,
284294
$settings
285295
);
286296

287-
return self::$_conn[$databaseID];
297+
return self::$_conn[$id];
288298
}
289299

290300
/**

0 commit comments

Comments
 (0)