Skip to content

Commit bc60de5

Browse files
author
Fredrick Peter
committed
helpers update
1 parent 05738c0 commit bc60de5

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ class PostClass extends DB{
14231423
| function name | Description |
14241424
|---------------------------|-----------------------------------------------|
14251425
| db() | Return instance of `new DB($options)` class |
1426+
| db_driver() | Returns instance of Database `PDO` Driver |
14261427
| db_config() | Same as `Direct DB Connection` get access to `DATABASE_CONNECTION` Constant after you call function |
14271428
| db_connection() | Same as `$db->dbConnection()` |
14281429
| db_query() | Same as `$db->dbQuery()` |

src/Query/MySqlExec.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ public function dbDriver()
7272
}
7373

7474
/**
75-
* Get Database Connection Status
75+
* Get Database Connection Constant Status
76+
* - When You connecto to Database using autoload or -- Direct connection
77+
* A Global Constant is Instantly defined for us.
78+
* This is to check if it has been defined or not
7679
*
77-
* @return bool\builder\Database\isConnection
80+
* @return bool\builder\Database\isDatabaseConnectionDefined
7881
*/
79-
public function isConnection()
82+
public function isDatabaseConnectionDefined()
8083
{
8184
return defined('DATABASE_CONNECTION');
8285
}

src/helpers.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010
use builder\Database\Migrations\Schema;
1111
use builder\Database\Migrations\Migration;
1212

13-
if (! function_exists('isConnection')) {
13+
if (! function_exists('isDatabaseConnectionDefined')) {
1414
/**
15-
* Get Database Connection Status
15+
* Get Database Connection Constant Status
16+
* - When You connecto to Database using autoload or -- Direct connection
17+
* A Global Constant is Instantly defined for us.
18+
* This is to check if it has been defined or not
1619
*
17-
* @return bool\builder\Database\isConnection
20+
* @return bool\builder\Database\isDatabaseConnectionDefined
1821
*/
19-
function isConnection()
22+
function isDatabaseConnectionDefined()
2023
{
21-
return (new MySqlExec)->isConnection();
24+
return (new MySqlExec)->isDatabaseConnectionDefined();
2225
}
2326
}
2427

@@ -46,7 +49,7 @@ function db(?array $options = [])
4649
function db_query()
4750
{
4851
// get query
49-
return isConnection()
52+
return isDatabaseConnectionDefined()
5053
? DATABASE_CONNECTION->dbQuery()
5154
: (new MySqlExec)->dbQuery();
5255
}
@@ -66,7 +69,7 @@ function db_query()
6669
*/
6770
function db_config(?array $options = [])
6871
{
69-
if ( ! isConnection() ) {
72+
if ( ! isDatabaseConnectionDefined() ) {
7073
define('DATABASE_CONNECTION', db($options));
7174
}
7275
}
@@ -84,7 +87,7 @@ function db_config(?array $options = [])
8487
function db_connection(?string $type = null)
8588
{
8689
// get database connection
87-
$connection = isConnection()
90+
$connection = isDatabaseConnectionDefined()
8891
? DATABASE_CONNECTION->dbConnection()
8992
: db()->dbConnection();
9093

@@ -98,10 +101,10 @@ function db_connection(?string $type = null)
98101
*
99102
* @return mixed\builder\Database\getDriver
100103
*/
101-
function driver()
104+
function db_driver()
102105
{
103106
// get database connection
104-
return isConnection()
107+
return isDatabaseConnectionDefined()
105108
? DATABASE_CONNECTION->dbConnection()['driver']
106109
: db()->dbConnection()['driver'];
107110
}
@@ -333,7 +336,7 @@ function app_data()
333336
: env_orm()->getDirectory();
334337

335338
// get database
336-
$database = isConnection()
339+
$database = isDatabaseConnectionDefined()
337340
? DATABASE_CONNECTION
338341
: db();
339342

0 commit comments

Comments
 (0)