Skip to content

Commit a13097e

Browse files
committed
more code coverage updates, doc-block updates, corrections
1 parent 026aec5 commit a13097e

File tree

11 files changed

+204
-76
lines changed

11 files changed

+204
-76
lines changed

lib/Config.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,6 @@ public function __construct(string $driver = '', array $arguments = null)
3131
}
3232
}
3333

34-
/**
35-
* Setup Connections for each SQL database class
36-
* @param string $driver - The vendor's SQL database driver name
37-
* @param string|array $arguments In the following:
38-
*
39-
* - user|args[0][1] // The database user name
40-
* - password|args[1][2] // The database users password
41-
* - database|args[1][2] // The name of the database
42-
* - host|args[3] // The host name or IP address of the database server,
43-
* Default is localhost
44-
* - port|args[4] // The database TCP/IP port,
45-
* Default is: 5432 - PostgreSQL, 3306 - MySQL
46-
*
47-
* for: mysqli
48-
* - (username, password, database, host, port, charset)
49-
* - charset|args[5] // The database charset,
50-
* Default is empty string
51-
*
52-
* for: postgresql
53-
* - (username, password, database, host, port)
54-
*
55-
* for: sqlserver
56-
* - (username, password, database, host, convertMysqlToMssqlQuery)
57-
* - convertMysqlToMssqlQuery[4] // convert Queries in MySql syntax to MS-SQL syntax
58-
* Default is false
59-
*
60-
* for: pdo
61-
* - (dsn, username, password, options, isFile?)
62-
* - dsn |args[0] // The PDO DSN connection parameter string
63-
* - options|args[3] // Array for setting connection options as MySQL
64-
* - isFile|args[4] // File based databases like SQLite don't need
65-
* user and password, they work with path in the dsn parameter
66-
* Default is false
67-
*
68-
* for: sqlite3
69-
* - (filePath, database) - filePath|args[0] // The path to open an SQLite database
70-
*/
7134
public static function initialize(string $driver = '', array $arguments = null)
7235
{
7336
return new self($driver, $arguments);

lib/ConfigAbstract.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,66 @@
2424
namespace ezsql;
2525

2626
/**
27-
* @method set/get{property} - a property that needs to be accessed
2827
*
2928
* @method void setDriver($args);
29+
* Database Sql driver name
3030
* @method void setDsn($args);
31+
* The PDO connection parameter string, database server in the DSN parameters
3132
* @method void setUser($args);
33+
* Database user name
3234
* @method void setPassword($args);
35+
* Database password for the given user
3336
* @method void setName($args);
37+
* Database name
3438
* @method void setHost($args);
39+
* Host name or IP address
3540
* @method void setPort($args);
41+
* TCP/IP port of PostgreSQL/MySQL
3642
* @method void setCharset($args);
43+
* Database charset
3744
* @method void setOptions($args);
45+
* The PDO array for connection options, MySQL connection charset, for example
3846
* @method void setIsFile($args);
47+
* Check PDO for whether it is a file based database connection, for example to a SQLite
48+
* database file, or not
3949
* @method void setToMssql($args);
50+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
51+
* Yes, there are some differences in query syntax.
4052
* @method void setToMysql($args);
53+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
54+
* Yes, there are some differences in query syntax.
4155
* @method void setPath($args);
56+
* The path to open an SQLite database
4257
*
4358
* @method string getDriver();
59+
* Database Sql driver name
4460
* @method string getDsn();
61+
* The PDO connection parameter string, database server in the DSN parameters
4562
* @method string getUser();
63+
* Database user name
4664
* @method string getPassword()
65+
* Database password for the given user
4766
* @method string getName();
67+
* Database name
4868
* @method string getHost();
69+
* Host name or IP address
4970
* @method string getPort();
71+
* TCP/IP port of PostgreSQL/MySQL
5072
* @method string getCharset();
73+
* Database charset
5174
* @method string getOptions();
75+
* The PDO array for connection options, MySQL connection charset, for example
5276
* @method string getToMysql();
77+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
78+
* Yes, there are some differences in query syntax.
5379
* @method bool getIsFile();
80+
* Check PDO for whether it is a file based database connection, for example to a SQLite
81+
* database file, or not
5482
* @method bool getToMssql();
83+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
84+
* Yes, there are some differences in query syntax.
5585
* @method string getPath();
86+
* The path to open an SQLite database
5687
*/
5788
abstract class ConfigAbstract
5889
{

lib/ConfigInterface.php

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,100 @@
44

55
/**
66
* @method void setDriver($args);
7+
* Database Sql driver name
78
* @method void setDsn($args);
9+
* The PDO connection parameter string, database server in the DSN parameters
810
* @method void setUser($args);
11+
* Database user name
912
* @method void setPassword($args);
13+
* Database password for the given user
1014
* @method void setName($args);
15+
* Database name
1116
* @method void setHost($args);
17+
* Host name or IP address
1218
* @method void setPort($args);
19+
* TCP/IP port of PostgreSQL/MySQL
1320
* @method void setCharset($args);
21+
* Database charset
1422
* @method void setOptions($args);
23+
* The PDO array for connection options, MySQL connection charset, for example
1524
* @method void setIsFile($args);
25+
* Check PDO for whether it is a file based database connection, for example to a SQLite
26+
* database file, or not
1627
* @method void setToMssql($args);
28+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
29+
* Yes, there are some differences in query syntax.
1730
* @method void setToMysql($args);
31+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
32+
* Yes, there are some differences in query syntax.
1833
* @method void setPath($args);
34+
* The path to open an SQLite database
1935
*
2036
* @method string getDriver();
37+
* Database Sql driver name
2138
* @method string getDsn();
39+
* The PDO connection parameter string, database server in the DSN parameters
2240
* @method string getUser();
41+
* Database user name
2342
* @method string getPassword()
43+
* Database password for the given user
2444
* @method string getName();
45+
* Database name
2546
* @method string getHost();
47+
* Host name or IP address
2648
* @method string getPort();
49+
* TCP/IP port of PostgreSQL/MySQL
2750
* @method string getCharset();
51+
* Database charset
2852
* @method string getOptions();
53+
* The PDO array for connection options, MySQL connection charset, for example
2954
* @method bool getIsFile();
30-
* @method bool getToMysql();
55+
* Check PDO for whether it is a file based database connection, for example to a SQLite
56+
* database file, or not
3157
* @method bool getToMssql();
58+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
59+
* Yes, there are some differences in query syntax.
60+
* @method bool getToMysql();
61+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
62+
* Yes, there are some differences in query syntax.
3263
* @method string getPath();
64+
* The path to open an SQLite database
3365
*/
3466
interface ConfigInterface
3567
{
3668
/**
3769
* Setup Connections for each SQL database class
3870
*
39-
* @param string $driver
40-
* @param string|array $arguments
71+
* @param string $driver - The vendor's SQL database driver name
72+
* @param array $arguments SQL connection parameters, in the following:
73+
*```js
74+
* [
75+
* user, // The database user name.
76+
* password, // The database users password.
77+
* database, // The name of the database.
78+
* host, // The host name or IP address of the database server. Default is localhost
79+
* port // The database TCP/IP port. Default is: 5432 - PostgreSQL, 3306 - MySQL
80+
* ]
81+
*```
82+
* for: **mysqli** - (`username`, `password`, `database`, `host`, `port`, `charset`)
83+
* - `charset` // The database charset,
84+
* Default is empty string
85+
*
86+
* for: **postgresql** - (`username`, `password`, `database`, `host`, `port`)
87+
*
88+
* for: **sqlserver** - (`username`, `password`, `database`, `host`, `convertMysqlToMssqlQuery`)
89+
* - `convertMysqlToMssqlQuery` // convert Queries in MySql syntax to MS-SQL syntax
90+
* Default is false
91+
*
92+
* for: **pdo** - (`dsn`, `username`, `password`, `options`, `isFile`?)
93+
* - `dsn` // The PDO DSN connection parameter string
94+
* - `options` // Array for setting connection options as MySQL
95+
* - `isFile` // File based databases like SQLite don't need
96+
* user and password, they work with path in the dsn parameter
97+
* Default is false
98+
*
99+
* for: **sqlite3** - (`filePath`, `database`)
100+
* - `filePath` // The path to open an SQLite database
41101
*/
42102
public static function initialize(string $driver = '', array $arguments = null);
43103
}

lib/Constants.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
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');
12+
// Use to set get_result output as json
13+
\define('JSON', 'json');
1214

1315
// Error messages
1416
\define('MISSING_CONFIGURATION', '<b>Fatal Error:</b> Missing configuration details to connect to database');
@@ -17,8 +19,6 @@
1719

1820
// ezQuery prepare placeholder/positional tag
1921
\define('_TAG', '__ez__');
20-
// Use to set get_result output as json
21-
\define('_JSON', 'json');
2222

2323
/**
2424
* Operator boolean expressions.

lib/Database.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,36 @@ public function __wakeup()
3232
* Initialize and connect a vendor database.
3333
*
3434
* @param string $vendor SQL driver
35-
* @param array $setting SQL connection parameters
35+
* @param array $setting SQL connection parameters, in the following:
36+
*```js
37+
* [
38+
* user, // The database user name.
39+
* password, // The database users password.
40+
* database, // The name of the database.
41+
* host, // The host name or IP address of the database server. Default is localhost
42+
* port // The database TCP/IP port. Default is: 5432 - PostgreSQL, 3306 - MySQL
43+
* ]
44+
*```
45+
* for: **mysqli** - (`username`, `password`, `database`, `host`, `port`, `charset`)
46+
* - `charset` // The database charset,
47+
* Default is empty string
48+
*
49+
* for: **postgresql** - (`username`, `password`, `database`, `host`, `port`)
50+
*
51+
* for: **sqlserver** - (`username`, `password`, `database`, `host`, `convertMysqlToMssqlQuery`)
52+
* - `convertMysqlToMssqlQuery` // convert Queries in MySql syntax to MS-SQL syntax
53+
* Default is false
54+
*
55+
* for: **pdo** - (`dsn`, `username`, `password`, `options`, `isFile`?)
56+
* - `dsn` // The PDO DSN connection parameter string
57+
* - `options` // Array for setting connection options as MySQL
58+
* - `isFile` // File based databases like SQLite don't need
59+
* user and password, they work with path in the dsn parameter
60+
* Default is false
61+
*
62+
* for: **sqlite3** - (`filePath`, `database`)
63+
* - `filePath` // The path to open an SQLite database
64+
*
3665
* @param string $tag Store the instance for later use
3766
* @return Database\ez_pdo|Database\ez_pgsql|Database\ez_sqlsrv|Database\ez_sqlite3|Database\ez_mysqli
3867
*/

lib/ezFunctions.php

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,38 @@
1616
* Initialize and connect a vendor's database.
1717
*
1818
* @param string $sqlDriver - SQL driver
19-
* @param array $connectionSetting - SQL connection parameters
19+
* @param array $connectionSetting SQL connection parameters, in the following:
20+
*```js
21+
* [
22+
* user, // The database user name.
23+
* password, // The database users password.
24+
* database, // The name of the database.
25+
* host, // The host name or IP address of the database server. Default is localhost
26+
* port // The database TCP/IP port. Default is: 5432 - PostgreSQL, 3306 - MySQL
27+
* ]
28+
*```
29+
* for: **mysqli** - (`username`, `password`, `database`, `host`, `port`, `charset`)
30+
* - `charset` // The database charset,
31+
* Default is empty string
32+
*
33+
* for: **postgresql** - (`username`, `password`, `database`, `host`, `port`)
34+
*
35+
* for: **sqlserver** - (`username`, `password`, `database`, `host`, `convertMysqlToMssqlQuery`)
36+
* - `convertMysqlToMssqlQuery` // convert Queries in MySql syntax to MS-SQL syntax
37+
* Default is false
38+
*
39+
* for: **pdo** - (`dsn`, `username`, `password`, `options`, `isFile`?)
40+
* - `dsn` // The PDO DSN connection parameter string
41+
* - `options` // Array for setting connection options as MySQL
42+
* - `isFile` // File based databases like SQLite don't need
43+
* user and password, they work with path in the dsn parameter
44+
* Default is false
45+
*
46+
* for: **sqlite3** - (`filePath`, `database`)
47+
* - `filePath` // The path to open an SQLite database
48+
*
2049
* @param string $instanceTag - Store the instance for later use
21-
* @return ezsql\Database\ez_pdo|ezsql\Database\ez_pgsql|ezsql\Database\ez_sqlsrv|ezsql\Database\ez_sqlite3|ezsql\Database\ez_mysqli
50+
* @return \ezsql\Database\ez_pdo|\ezsql\Database\ez_pgsql|\ezsql\Database\ez_sqlsrv|\ezsql\Database\ez_sqlite3|\ezsql\Database\ez_mysqli
2251
*/
2352
function database(string $sqlDriver = null, array $connectionSetting = null, string $instanceTag = null)
2453
{
@@ -29,7 +58,7 @@ function database(string $sqlDriver = null, array $connectionSetting = null, str
2958
* Returns an already initialized database instance that was created with an tag.
3059
*
3160
* @param string $getTag - An stored tag instance
32-
* @return ezsql\Database\ez_pdo|ezsql\Database\ez_pgsql|ezsql\Database\ez_sqlsrv|ezsql\Database\ez_sqlite3|ezsql\Database\ez_mysqli
61+
* @return \ezsql\Database\ez_pdo|\ezsql\Database\ez_pgsql|\ezsql\Database\ez_sqlsrv|\ezsql\Database\ez_sqlite3|\ezsql\Database\ez_mysqli
3362
*/
3463
function tagInstance(string $getTag = null)
3564
{
@@ -39,10 +68,11 @@ function tagInstance(string $getTag = null)
3968
/**
4069
* Initialize an mysqli database.
4170
*
42-
* @param array $databaseSetting - SQL connection parameters
71+
* @param array $databaseSetting SQL connection parameters
72+
* - [ `username`, `password`, `database`, host, port, charset ]
4373
* @param string $instanceTag - Store the instance for later use
4474
*
45-
* @return ezsql\Database\ez_mysqli
75+
* @return \ezsql\Database\ez_mysqli
4676
*/
4777
function mysqlInstance(array $databaseSetting = null, string $instanceTag = null)
4878
{
@@ -52,10 +82,11 @@ function mysqlInstance(array $databaseSetting = null, string $instanceTag = null
5282
/**
5383
* Initialize an pgsql database.
5484
*
55-
* @param array $databaseSetting - SQL connection parameters
85+
* @param array $databaseSetting SQL connection parameters
86+
* - [ `username`, `password`, `database`, host, port ]
5687
* @param string $instanceTag - Store the instance for later use
5788
*
58-
* @return ezsql\Database\ez_pgsql
89+
* @return \ezsql\Database\ez_pgsql
5990
*/
6091
function pgsqlInstance(array $databaseSetting = null, string $instanceTag = null)
6192
{
@@ -68,7 +99,7 @@ function pgsqlInstance(array $databaseSetting = null, string $instanceTag = null
6899
* @param array $databaseSetting - SQL connection parameters
69100
* @param string $instanceTag - Store the instance for later use
70101
*
71-
* @return ezsql\Database\ez_sqlsrv
102+
* @return \ezsql\Database\ez_sqlsrv
72103
*/
73104
function mssqlInstance(array $databaseSetting = null, string $instanceTag = null)
74105
{
@@ -81,7 +112,7 @@ function mssqlInstance(array $databaseSetting = null, string $instanceTag = null
81112
* @param array $databaseSetting - SQL connection parameters
82113
* @param string $instanceTag - Store the instance for later use
83114
*
84-
* @return ezsql\Database\ez_pdo
115+
* @return \ezsql\Database\ez_pdo
85116
*/
86117
function pdoInstance(array $databaseSetting = null, string $instanceTag = null)
87118
{
@@ -94,7 +125,7 @@ function pdoInstance(array $databaseSetting = null, string $instanceTag = null)
94125
* @param array $databaseSetting - SQL connection parameters
95126
* @param string $instanceTag - Store the instance for later use
96127
*
97-
* @return ezsql\Database\ez_sqlite3
128+
* @return \ezsql\Database\ez_sqlite3
98129
*/
99130
function sqliteInstance(array $databaseSetting = null, string $instanceTag = null)
100131
{
@@ -198,7 +229,7 @@ function dropColumn(string $columnName, ...$data)
198229
*
199230
* @return string certificate path
200231
*/
201-
function createCertificate(
232+
function create_certificate(
202233
string $privatekeyFile = 'certificate.key',
203234
string $certificateFile = 'certificate.crt',
204235
string $signingFile = 'certificate.csr',

0 commit comments

Comments
 (0)