Skip to content

Commit 8cfc804

Browse files
committed
commits from branch v5, new version, major breaking changes, updated docs/doc-blocks
- The use of `namespace` in the `global` functions **ezFunctions.php** file. Usage of the **global** functions will require the user to begin a `.php` file something like: ```php use function ezsql\functions\where; // Or use function ezsql\functions\{ getInstance, selecting, inserting, }; ``` - Class properties that was accessible by magic methods `get/set`, now PSR 1 camelCase. - update class libraries and tests to match PSR 1, but still backwards with previous way. - Renamed `select` of `ez_mysqli` to `dbSelect`. - Renamed class method and behavior of `selecting` to `select`. - `selecting`, and new `inserting` methods, can be called without table name, only the other necessary parameters: - The table *name* with *prefix*, can be preset/stored with methods `tableSetup(name, prefix), or setTable(name), setPrefix(append)`, if called without presetting, `false` is returned. - This **feature** will be added to **all** database *CRUD* access methods , each method name will have an `ing` ending added. - Removed global functions where `table` name passed in, use functions as outlined above using preset table names ending with `ing`.
1 parent df25ea6 commit 8cfc804

31 files changed

+1748
-799
lines changed

README.md

Lines changed: 118 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,36 @@
66
[![codecov](https://codecov.io/gh/ezSQL/ezSQL/branch/master/graph/badge.svg)](https://codecov.io/gh/ezSQL/ezSQL)
77
[![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)
88
[![Maintainability](https://api.codeclimate.com/v1/badges/6f6107f25e9de7bf4272/maintainability)](https://codeclimate.com/github/ezSQL/ezsql/maintainability)
9-
[![Total Downloads](https://poser.pugx.org/ezSQL/ezsql/downloads)](https://packagist.org/packages/ezSQL/ezsql)
9+
[![Total Downloads](https://poser.pugx.org/ezsql/ezsql/downloads)](https://packagist.org/packages/ezsql/ezsql)
1010

1111
***A class to make it very easy to deal with database connections.***
1212

13-
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 [__Version 5__](https://github.com/ezSQL/ezsql/tree/v5) which will break users of **version 4**.
14+
15+
Mainly by:
16+
17+
- The use of `namespace` in the `global` functions **ezFunctions.php** file.
18+
Usage of the **global** functions will require the user to begin a `.php` file something like:
19+
20+
```php
21+
use function ezsql\functions\where;
22+
// Or
23+
use function ezsql\functions\{
24+
getInstance,
25+
selecting,
26+
inserting,
27+
};
28+
```
29+
30+
- Class properties that was accessible by magic methods `get/set`, now PSR 1 camelCase.
31+
- Renamed `select` of `ez_mysqli` to `dbSelect`.
32+
- Renamed class method and behavior of `selecting` to `select`.
33+
- `selecting`, and new `inserting` methods, can be called without table name, only the other necessary parameters:
34+
- The table *name* with *prefix*, can be preset/stored with methods `tableSetup(name, prefix), or setTable(name), setPrefix(append)`, if called without presetting, `false` is returned.
35+
- This **feature** will be added to **all** database *CRUD* access methods , each method name will have an `ing` ending added.
36+
- Removed global functions where `table` name passed in, use functions using preset table names ending with `ing`.
37+
38+
[__Version 4__](https://github.com/ezSQL/ezsql/tree/v4) has many modern programming practices in which will break users of version 3.
1439

1540
[__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.
1641

@@ -115,7 +140,7 @@ prepareOff(); // When off shortcut SQL Methods calls will use vendors escape rou
115140
* `orderBy($orderBy, $order);`
116141
* `limit($numberOf, $offset = null)`
117142
* `where( ...$whereConditions);`
118-
* `selecting(string $table = null, $columnFields = '*', ...$conditions);`
143+
* `select(string $table = null, $columnFields = '*', ...$conditions);`
119144
* `create_select(string $newTable, $fromColumns, $oldTable = null, ...$conditions);`
120145
* `select_into(string $newTable, $fromColumns, $oldTable = null, ...$conditions);`
121146
* `update(string $table = null, $keyAndValue, ...$whereConditions);`
@@ -158,11 +183,18 @@ grouping( eq(key, value, combiner ), eq(key, value, combiner ) )
158183
```
159184

160185
```php
161-
// Supply the the whole query string, and placing '?' within
162-
// With the same number of arguments in an array.
163-
// It will determine arguments type, execute, and return results.
186+
// Note: The usage of this method will require the user/developer to check
187+
// if `query_string` or `param_array` is valid.
188+
//
189+
// This is really an `private` internal method for other shortcut methods,
190+
// it's made public for `class development` usage only.
191+
//
192+
//
193+
// Supply the the whole `query` string, and placing '?' within, with the same number of arguments in an array.
194+
// It will then determine arguments type, execute, and return results.
164195
query_prepared(string $query_string, array $param_array);
165-
// Will need to call to get last successful query result, will return an object array
196+
// You will need to call this method to get last successful query result.
197+
// It wll return an object array.
166198
queryResult();
167199
```
168200

@@ -180,13 +212,13 @@ $db->insert('profile', $values);
180212
$db->insert('profile', ['name' => 'john john', 'email' => 'john@email', 'phone' => 123456]);
181213

182214
// returns result set given the table name, column fields, and ...conditions
183-
$result = $db->selecting('profile', 'phone', eq('email', $email), between('id', 1, $values));
215+
$result = $db->select('profile', 'phone', eq('email', $email), between('id', 1, $values));
184216

185217
foreach ($result as $row) {
186218
echo $row->phone;
187219
}
188220

189-
$result = $db->selecting('profile', 'name, email',
221+
$result = $db->select('profile', 'name, email',
190222
// Conditionals can also be called, stacked with other functions like:
191223
// innerJoin(), leftJoin(), rightJoin(), fullJoin()
192224
// as (leftTable, rightTable, leftColumn, rightColumn, tableAs, equal condition),
@@ -222,6 +254,83 @@ foreach ($result as $row) {
222254
}
223255
```
224256

257+
Most of shortcut methods have counter **global** _functions_ available.
258+
They can only be access by beginning your `.php` file like:
259+
260+
```php
261+
use function ezsql\functions\functionBelow;
262+
// Or as here, a complete list.
263+
use function ezsql\functions\{
264+
database,
265+
mysqlInstance,
266+
pgsqlInstance,
267+
mssqlInstance,
268+
sqliteInstance,
269+
pdoInstance,
270+
tagInstance,
271+
setInstance,
272+
getInstance,
273+
clearInstance,
274+
///
275+
getVendor,
276+
to_string,
277+
cleanInput,
278+
createCertificate,
279+
///
280+
column,
281+
primary,
282+
foreign,
283+
unique,
284+
index,
285+
addColumn,
286+
dropColumn,
287+
///
288+
eq,
289+
neq,
290+
ne,
291+
lt,
292+
lte,
293+
gt,
294+
gte,
295+
isNull,
296+
isNotNull,
297+
like,
298+
in,
299+
notLike,
300+
notIn,
301+
between,
302+
notBetween,
303+
///
304+
select_into,
305+
insert_select,
306+
create_select,
307+
where,
308+
grouping,
309+
groupBy,
310+
having,
311+
orderBy,
312+
limit,
313+
innerJoin,
314+
leftJoin,
315+
rightJoin,
316+
fullJoin,
317+
union,
318+
unionAll,
319+
///
320+
creating,
321+
deleting,
322+
dropping,
323+
replacing,
324+
selecting,
325+
inserting,
326+
table_setup,
327+
set_table,
328+
set_prefix
329+
};
330+
```
331+
332+
For the functions **usage/docs** see [ezFunctions.php](https://github.com/ezSQL/ezsql/blob/v5/lib/ezFunctions.php).
333+
225334
## For Authors and **[Contributors](https://github.com/ezSQL/ezsql/blob/master/CONTRIBUTORS.md)**
226335

227336
## Contributing

lib/Config.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,6 @@
88
use ezsql\ConfigAbstract;
99
use ezsql\ConfigInterface;
1010

11-
/**
12-
* @method void setDriver($args);
13-
* @method void setDsn($args);
14-
* @method void setUser($args);
15-
* @method void setPassword($args);
16-
* @method void setName($args);
17-
* @method void setHost($args);
18-
* @method void setPort($args);
19-
* @method void setCharset($args);
20-
* @method void setOptions($args);
21-
* @method void setIsFile($args);
22-
* @method void setToMssql($args);
23-
* @method void setPath($args);
24-
*
25-
* @method string getDriver();
26-
* @method string getDsn();
27-
* @method string getUser();
28-
* @method string getPassword()
29-
* @method string getName();
30-
* @method string getHost();
31-
* @method string getPort();
32-
* @method string getCharset();
33-
* @method string getOptions();
34-
* @method bool getIsFile();
35-
* @method bool getToMssql();
36-
* @method string getPath();
37-
*/
3811
class Config extends ConfigAbstract implements ConfigInterface
3912
{
4013
public function __construct(string $driver = '', array $arguments = null)

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.1.0');
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: 6 additions & 5 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
{
@@ -30,15 +31,15 @@ public function __wakeup()
3031
/**
3132
* Initialize and connect a vendor database.
3233
*
33-
* @param mixed $vendor - SQL driver
34-
* @param mixed $setting - SQL connection parameters
35-
* @param mixed $tag - Store the instance for later use
34+
* @param string $vendor SQL driver
35+
* @param array $setting SQL connection parameters
36+
* @param string $tag Store the instance for later use
3637
* @return Database\ez_pdo|Database\ez_pgsql|Database\ez_sqlsrv|Database\ez_sqlite3|Database\ez_mysqli
3738
*/
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
}

0 commit comments

Comments
 (0)