Skip to content

Commit a56baf4

Browse files
committed
namespace ezFunctions.php file global functions, update database files and tests
- this is a breaking change requiring major version change
1 parent 2271997 commit a56baf4

29 files changed

+290
-74
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22

33
[![Windows](https://github.com/ezSQL/ezsql/workflows/Windows/badge.svg?branch=v5)](https://github.com/ezSQL/ezsql/actions?query=workflow%3AWindows)
44
[![Linux](https://github.com/ezSQL/ezsql/workflows/Linux/badge.svg?branch=v5)](https://github.com/ezSQL/ezsql/actions?query=workflow%3ALinux)
5-
[![codecov](https://codecov.io/gh/ezSQL/ezSQL/branch/master/graph/badge.svg)](https://codecov.io/gh/ezSQL/ezSQL)
5+
[![macOS](https://github.com/ezSQL/ezsql/workflows/macOS/badge.svg?branch=v5)](https://github.com/ezSQL/ezsql/actions?query=workflow%3AmacOS)
6+
[![codecov](https://codecov.io/gh/ezSQL/ezSQL/branch/v5/graph/badge.svg)](https://codecov.io/gh/ezSQL/ezSQL)
67
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/aad1f6aaaaa14f60933e75615da900b8)](https://www.codacy.com/app/techno-express/ezsql?utm_source=github.com&utm_medium=referral&utm_content=ezSQL/ezsql&utm_campaign=Badge_Grade)
78
[![Maintainability](https://api.codeclimate.com/v1/badges/6f6107f25e9de7bf4272/maintainability)](https://codeclimate.com/github/ezSQL/ezsql/maintainability)
8-
[![Total Downloads](https://poser.pugx.org/jv2222/ezsql/downloads)](https://packagist.org/packages/jv2222/ezsql)
9+
[![Total Downloads](https://poser.pugx.org/ezsql/ezsql/downloads)](https://packagist.org/packages/ezsql/ezsql)
910

1011
***A class to make it very easy to deal with database connections.***
1112

12-
This is [__version 4__](https://github.com/ezSQL/ezsql/tree/v4) that has many modern programming practices in which will break users of version 3.
13+
This is a [WIP] of [__version 5__](https://github.com/ezSQL/ezsql/tree/v5) which will break users of **version 4**, mainly by the use of `namespace` in the `global` functions **ezFunctions.php** file.
14+
15+
Usage of the **global** functions will require the user to begin a `.php` file something like:
16+
17+
```php
18+
use function ezsql\functions\where;
19+
// Or
20+
use function ezsql\functions\{
21+
getInstance,
22+
select,
23+
insert,
24+
};
25+
```
26+
27+
[__version 4__](https://github.com/ezSQL/ezsql/tree/v4) has many modern programming practices in which will break users of version 3.
1328

1429
[__Version 3__](https://github.com/ezSQL/ezsql/tree/v3) broke version 2.1.7 in one major way, it required *PHP 5.6*. Which drop mysql extension support, other than that, nothing as far using the library was changed, only additional features.
1530

lib/ConfigAbstract.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@
2525

2626
/**
2727
* @method set/get{property} - a property that needs to be accessed
28+
*
29+
* @method void setDriver($args);
30+
* @method void setDsn($args);
31+
* @method void setUser($args);
32+
* @method void setPassword($args);
33+
* @method void setName($args);
34+
* @method void setHost($args);
35+
* @method void setPort($args);
36+
* @method void setCharset($args);
37+
* @method void setOptions($args);
38+
* @method void setIsFile($args);
39+
* @method void setToMssql($args);
40+
* @method void setToMysql($args);
41+
* @method void setPath($args);
42+
*
43+
* @method string getDriver();
44+
* @method string getDsn();
45+
* @method string getUser();
46+
* @method string getPassword()
47+
* @method string getName();
48+
* @method string getHost();
49+
* @method string getPort();
50+
* @method string getCharset();
51+
* @method string getOptions();
52+
* @method string getToMysql();
53+
* @method bool getIsFile();
54+
* @method bool getToMssql();getToMssql
55+
* @method string getPath();
2856
*/
2957
abstract class ConfigAbstract
3058
{

lib/ConfigInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* @method void setCharset($args);
1414
* @method void setOptions($args);
1515
* @method void setIsFile($args);
16+
* @method void setToMssql($args);
1617
* @method void setToMysql($args);
1718
* @method void setPath($args);
1819
*
@@ -27,6 +28,7 @@
2728
* @method string getOptions();
2829
* @method bool getIsFile();
2930
* @method bool getToMysql();
31+
* @method bool getToMssql();
3032
* @method string getPath();
3133
*/
3234
interface ConfigInterface

lib/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* ezsqlModel Constants
77
*/
8-
\defined('EZSQL_VERSION') or \define('EZSQL_VERSION', '4.0.12');
8+
\defined('EZSQL_VERSION') or \define('EZSQL_VERSION', '5.0.0');
99
\defined('OBJECT') or \define('OBJECT', 'OBJECT');
1010
\defined('ARRAY_A') or \define('ARRAY_A', 'ARRAY_A');
1111
\defined('ARRAY_N') or \define('ARRAY_N', 'ARRAY_N');

lib/Database.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace ezsql;
66

77
use ezsql\DInjector;
8+
use function ezsql\functions\setInstance;
89

910
class Database
1011
{
@@ -38,7 +39,7 @@ public function __wakeup()
3839
public static function initialize(?string $vendor = null, ?array $setting = null, ?string $tag = null)
3940
{
4041
if (isset(self::$instances[$vendor]) && empty($setting) && empty($tag))
41-
return \setInstance(self::$instances[$vendor]) ? self::$instances[$vendor] : false;
42+
return setInstance(self::$instances[$vendor]) ? self::$instances[$vendor] : false;
4243

4344
if (empty($vendor) || empty($setting)) {
4445
throw new \Exception(\MISSING_CONFIGURATION);
@@ -58,7 +59,7 @@ public static function initialize(?string $vendor = null, ?array $setting = null
5859
}
5960
}
6061

61-
\setInstance($GLOBALS['ez' . $key]);
62+
setInstance($GLOBALS['ez' . $key]);
6263
return $GLOBALS['ez' . $key];
6364
}
6465
}

lib/Database/ez_mysqli.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ezsql\ezsqlModel;
99
use ezsql\ConfigInterface;
1010
use ezsql\DatabaseInterface;
11+
use function ezsql\functions\setInstance;
1112

1213
class ez_mysqli extends ezsqlModel implements DatabaseInterface
1314
{
@@ -45,7 +46,7 @@ public function __construct(ConfigInterface $settings = null)
4546

4647
if (empty($GLOBALS['ez' . \MYSQLI]))
4748
$GLOBALS['ez' . \MYSQLI] = $this;
48-
\setInstance($this);
49+
setInstance($this);
4950
} // __construct
5051

5152
public function settings()

lib/Database/ez_pdo.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use ezsql\ezsqlModel;
1010
use ezsql\ConfigInterface;
1111
use ezsql\DatabaseInterface;
12+
use function ezsql\functions\setInstance;
1213

1314
class ez_pdo extends ezsqlModel implements DatabaseInterface
1415
{
@@ -49,7 +50,7 @@ public function __construct(ConfigInterface $settings = null)
4950

5051
if (empty($GLOBALS['ez' . \Pdo]))
5152
$GLOBALS['ez' . \Pdo] = $this;
52-
\setInstance($this);
53+
setInstance($this);
5354
} // __construct
5455

5556
public function settings()

lib/Database/ez_pgsql.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ezsql\ezsqlModel;
99
use ezsql\ConfigInterface;
1010
use ezsql\DatabaseInterface;
11+
use function ezsql\functions\setInstance;
1112

1213
class ez_pgsql extends ezsqlModel implements DatabaseInterface
1314
{
@@ -45,7 +46,7 @@ public function __construct(ConfigInterface $settings = null)
4546

4647
if (empty($GLOBALS['ez' . \PGSQL]))
4748
$GLOBALS['ez' . \PGSQL] = $this;
48-
\setInstance($this);
49+
setInstance($this);
4950
} // __construct
5051

5152
public function settings()

lib/Database/ez_sqlite3.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ezsql\ezsqlModel;
99
use ezsql\ConfigInterface;
1010
use ezsql\DatabaseInterface;
11+
use function ezsql\functions\setInstance;
1112

1213
class ez_sqlite3 extends ezsqlModel implements DatabaseInterface
1314
{
@@ -52,7 +53,7 @@ public function __construct(ConfigInterface $settings = null)
5253

5354
if (!isset($GLOBALS['ez' . \SQLITE3]))
5455
$GLOBALS['ez' . \SQLITE3] = $this;
55-
\setInstance($this);
56+
setInstance($this);
5657
}
5758

5859
public function settings()

lib/Database/ez_sqlsrv.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ezsql\ezsqlModel;
99
use ezsql\ConfigInterface;
1010
use ezsql\DatabaseInterface;
11+
use function ezsql\functions\setInstance;
1112

1213
class ez_sqlsrv extends ezsqlModel implements DatabaseInterface
1314
{
@@ -54,7 +55,7 @@ public function __construct(ConfigInterface $settings = null)
5455

5556
if (empty($GLOBALS['ez' . \SQLSRV]))
5657
$GLOBALS['ez' . \SQLSRV] = $this;
57-
\setInstance($this);
58+
setInstance($this);
5859
}
5960

6061
public function settings()

0 commit comments

Comments
 (0)