Skip to content

Commit 63aa7f5

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents fb1176d + 5971a56 commit 63aa7f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2811
-3488
lines changed

.gitattributes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
/.travis.yml export-ignore
44
/.appveyor.yml export-ignore
55
/.travis.yml export-ignore
6-
#.vscode export-ignore
6+
/.vscode export-ignore
77
/codecov.yml export-ignore
88
/examples export-ignore
9-
#phpunit.xml.dist export-ignore
10-
#tests export-ignore
9+
/phpunit.xml.dist export-ignore
10+
/tests export-ignore
1111
/docs export-ignore
1212
/tmp export-ignore

lib/Config.php

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace ezsql;
@@ -8,32 +9,32 @@
89
use ezsql\ConfigInterface;
910

1011
/**
11-
* @method void setDriver($args);
12-
* @method void setDsn($args);
13-
* @method void setUser($args);
14-
* @method void setPassword($args);
15-
* @method void setName($args);
16-
* @method void setHost($args);
17-
* @method void setPort($args);
18-
* @method void setCharset($args);
19-
* @method void setOptions($args);
20-
* @method void setIsFile($args);
21-
* @method void setToMssql($args);
22-
* @method void setPath($args);
23-
*
24-
* @method string getDriver();
25-
* @method string getDsn();
26-
* @method string getUser();
27-
* @method string getPassword()
28-
* @method string getName();
29-
* @method string getHost();
30-
* @method string getPort();
31-
* @method string getCharset();
32-
* @method string getOptions();
33-
* @method bool getIsFile();
34-
* @method bool getToMssql();
35-
* @method string getPath();
36-
*/
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+
*/
3738
class Config extends ConfigAbstract implements ConfigInterface
3839
{
3940
public function __construct(string $driver = '', array $arguments = null)
@@ -44,7 +45,7 @@ public function __construct(string $driver = '', array $arguments = null)
4445
} else {
4546
$this->setDriver($sql);
4647
if ($sql == \Pdo) {
47-
$this->setupPdo($arguments);
48+
$this->setupPdo($arguments);
4849
} elseif ($sql == \POSTGRESQL) {
4950
$this->setupPgsql($arguments);
5051
} elseif ($sql == \SQLSRV) {
@@ -61,49 +62,49 @@ public function __construct(string $driver = '', array $arguments = null)
6162
* Setup Connections for each SQL database class
6263
* @param string $driver - The vendor's SQL database driver name
6364
* @param string|array $arguments In the following:
64-
*
65+
*
6566
* - user|args[0][1] // The database user name
6667
* - password|args[1][2] // The database users password
6768
* - database|args[1][2] // The name of the database
6869
* - host|args[3] // The host name or IP address of the database server,
6970
* Default is localhost
70-
* - port|args[4] // The database TCP/IP port,
71+
* - port|args[4] // The database TCP/IP port,
7172
* Default is: 5432 - PostgreSQL, 3306 - MySQL
72-
*
73-
* for: mysqli
73+
*
74+
* for: mysqli
7475
* - (username, password, database, host, port, charset)
75-
* - charset|args[5] // The database charset,
76+
* - charset|args[5] // The database charset,
7677
* Default is empty string
77-
*
78-
* for: postgresql
78+
*
79+
* for: postgresql
7980
* - (username, password, database, host, port)
80-
*
81-
* for: sqlserver
81+
*
82+
* for: sqlserver
8283
* - (username, password, database, host, convertMysqlToMssqlQuery)
8384
* - convertMysqlToMssqlQuery[4] // convert Queries in MySql syntax to MS-SQL syntax
8485
* Default is false
85-
*
86+
*
8687
* for: pdo
87-
* - (dsn, username, password, options, isFile?)
88+
* - (dsn, username, password, options, isFile?)
8889
* - dsn |args[0] // The PDO DSN connection parameter string
8990
* - options|args[3] // Array for setting connection options as MySQL
9091
* - isFile|args[4] // File based databases like SQLite don't need
9192
* user and password, they work with path in the dsn parameter
9293
* Default is false
93-
*
94-
* for: sqlite3
94+
*
95+
* for: sqlite3
9596
* - (filePath, database) - filePath|args[0] // The path to open an SQLite database
9697
*/
9798
public static function initialize(string $driver = '', array $arguments = null)
9899
{
99100
return new self($driver, $arguments);
100101
}
101102

102-
private function setupMysqli($args)
103+
private function setupMysqli($args)
103104
{
104-
if ( ! \function_exists('mysqli_connect') )
105+
if (!\function_exists('mysqli_connect'))
105106
throw new Exception('<b>Fatal Error:</b> ez_mysql requires mySQLi Lib to be compiled and or linked in to the PHP engine');
106-
107+
107108
if (\count($args) >= 3) {
108109
$this->setUser($args[0]);
109110
$this->setPassword($args[1]);
@@ -116,25 +117,25 @@ private function setupMysqli($args)
116117
throw new Exception(\MISSING_CONFIGURATION);
117118
}
118119

119-
private function setupPdo($args)
120+
private function setupPdo($args)
120121
{
121-
if ( ! \class_exists('PDO') )
122-
throw new Exception('<b>Fatal Error:</b> ez_pdo requires PDO Lib to be compiled and or linked in to the PHP engine');
122+
if (!\class_exists('PDO'))
123+
throw new Exception('<b>Fatal Error:</b> ez_pdo requires PDO Lib to be compiled and or linked in to the PHP engine');
123124
if (\count($args) >= 3) {
124125
$this->setDsn($args[0]);
125126
$this->setUser($args[1]);
126127
$this->setPassword($args[2]);
127128
$this->setOptions(empty($args[3]) ? $this->getOptions() : $args[3]);
128129
$this->setIsFile(empty($args[4]) ? $this->getIsFile() : $args[4]);
129130
} else
130-
throw new Exception(\MISSING_CONFIGURATION);
131+
throw new Exception(\MISSING_CONFIGURATION);
131132
}
132133

133-
private function setupSqlsrv($args)
134+
private function setupSqlsrv($args)
134135
{
135-
if ( ! \function_exists('sqlsrv_connect') )
136+
if (!\function_exists('sqlsrv_connect'))
136137
throw new Exception('<b>Fatal Error:</b> ez_sqlsrv requires the php_sqlsrv.dll or php_pdo_sqlsrv.dll to be installed. Also enable MS-SQL extension in PHP.ini file ');
137-
138+
138139
if (\count($args) >= 3) {
139140
$this->setUser($args[0]);
140141
$this->setPassword($args[1]);
@@ -145,11 +146,11 @@ private function setupSqlsrv($args)
145146
throw new Exception(\MISSING_CONFIGURATION);
146147
}
147148

148-
private function setupPgsql($args)
149+
private function setupPgsql($args)
149150
{
150-
if ( ! \function_exists('pg_connect') )
151+
if (!\function_exists('pg_connect'))
151152
throw new Exception('<b>Fatal Error:</b> ez_pgsql requires PostgreSQL Lib to be compiled and or linked in to the PHP engine');
152-
153+
153154
if (count($args) >= 3) {
154155
$this->setUser($args[0]);
155156
$this->setPassword($args[1]);
@@ -160,14 +161,15 @@ private function setupPgsql($args)
160161
throw new Exception(\MISSING_CONFIGURATION);
161162
}
162163

163-
private function setupSqlite3($args) {
164-
if ( ! \class_exists('SQLite3') )
164+
private function setupSqlite3($args)
165+
{
166+
if (!\class_exists('SQLite3'))
165167
throw new Exception('<b>Fatal Error:</b> ez_sqlite3 requires SQLite3 Lib to be compiled and or linked in to the PHP engine');
166-
168+
167169
if (\count($args) == 2) {
168170
$this->setPath($args[0]);
169171
$this->setName($args[1]);
170172
} else
171173
throw new Exception(\MISSING_CONFIGURATION);
172174
}
173-
}
175+
}

lib/ConfigAbstract.php

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php
1+
<?php
2+
23
/**
34
* Author: Lawrence Stubbs <[email protected]>
45
*
@@ -17,104 +18,105 @@
1718
* This software consists of voluntary contributions made by many individuals
1819
* and is licensed under the MIT license.
1920
*/
21+
2022
declare(strict_types=1);
2123

2224
namespace ezsql;
2325

2426
/**
25-
* @method set/get{property} - a property that needs to be accessed
26-
*/
27-
abstract class ConfigAbstract
27+
* @method set/get{property} - a property that needs to be accessed
28+
*/
29+
abstract class ConfigAbstract
2830
{
2931
/**
30-
* Database Sql driver name
31-
* @var string
32-
*/
32+
* Database Sql driver name
33+
* @var string
34+
*/
3335
private $driver;
3436

3537
/**
36-
* Database user name
37-
* @var string
38-
*/
38+
* Database user name
39+
* @var string
40+
*/
3941
private $user = '';
4042

4143
/**
42-
* Database password for the given user
43-
* @var string
44-
*/
44+
* Database password for the given user
45+
* @var string
46+
*/
4547
private $password = '';
4648

4749
/**
48-
* Database name
49-
* @var string
50-
*/
50+
* Database name
51+
* @var string
52+
*/
5153
private $name = '';
5254

5355
/**
54-
* Host name or IP address
55-
* @var string
56-
*/
56+
* Host name or IP address
57+
* @var string
58+
*/
5759
private $host = 'localhost';
5860

5961
/**
60-
* Database charset
61-
* @var string Default is utf8
62-
*/
62+
* Database charset
63+
* @var string Default is utf8
64+
*/
6365
private $charset = 'utf8';
6466

6567
/**
66-
* The PDO connection parameter string, database server in the DSN parameters
67-
* @var string Default is empty string
68-
*/
68+
* The PDO connection parameter string, database server in the DSN parameters
69+
* @var string Default is empty string
70+
*/
6971
private $dsn = '';
7072

7173
/**
72-
* The PDO array for connection options, MySQL connection charset, for example
73-
* @var array
74-
*/
74+
* The PDO array for connection options, MySQL connection charset, for example
75+
* @var array
76+
*/
7577
private $options = array();
76-
78+
7779
/**
78-
* Check PDO for whether it is a file based database connection, for example to a SQLite
79-
* database file, or not
80-
* @var boolean Default is false
81-
*/
80+
* Check PDO for whether it is a file based database connection, for example to a SQLite
81+
* database file, or not
82+
* @var boolean Default is false
83+
*/
8284
private $isfile = false;
8385

8486
/**
85-
* TCP/IP port of PostgreSQL
86-
* @var string Default is port 5432
87-
*/
87+
* TCP/IP port of PostgreSQL
88+
* @var string Default is port 5432
89+
*/
8890
private $port = '5432';
8991

9092
/**
91-
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
92-
* Yes, there are some differences in query syntax.
93-
*/
93+
* If we want to convert Queries in MySql syntax to MS-SQL syntax.
94+
* Yes, there are some differences in query syntax.
95+
*/
9496
private $tomssql = true;
9597

9698
/**
97-
* The path to open an SQLite database
98-
*/
99+
* The path to open an SQLite database
100+
*/
99101
private $path = '';
100-
101-
/**
102-
* Use for Calling Non-Existent Functions, handling Getters and Setters
103-
* @property-read function
104-
* @property-write args
105-
*
106-
* @return mixed
107-
*/
108-
public function __call($function, $args)
109-
{
110-
$prefix = \substr($function, 0, 3);
111-
$property = \strtolower(substr($function, 3, \strlen($function)));
112-
if (($prefix == 'set') && \property_exists($this, $property)) {
113-
$this->$property = $args[0];
114-
} elseif (($prefix == 'get') && \property_exists($this, $property)) {
115-
return $this->$property;
116-
} else {
117-
throw new \Exception("$function does not exist");
118-
}
119-
}
120-
}
102+
103+
/**
104+
* Use for Calling Non-Existent Functions, handling Getters and Setters
105+
* @property-read function
106+
* @property-write args
107+
*
108+
* @return mixed
109+
*/
110+
public function __call($function, $args)
111+
{
112+
$prefix = \substr($function, 0, 3);
113+
$property = \strtolower(substr($function, 3, \strlen($function)));
114+
if (($prefix == 'set') && \property_exists($this, $property)) {
115+
$this->$property = $args[0];
116+
} elseif (($prefix == 'get') && \property_exists($this, $property)) {
117+
return $this->$property;
118+
} else {
119+
throw new \Exception("$function does not exist");
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)