11<?php
2+
23declare (strict_types=1 );
34
45namespace ezsql ;
89use 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+ */
3738class 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+ }
0 commit comments