55namespace ezsql \Database ;
66
77use Exception ;
8+ use ezsql \Db ;
89use ezsql \ezsqlModel ;
910use ezsql \ConfigInterface ;
1011use ezsql \DatabaseInterface ;
11- use function ezsql \functions \setInstance ;
1212
1313class ez_pdo extends ezsqlModel implements DatabaseInterface
1414{
@@ -35,7 +35,7 @@ class ez_pdo extends ezsqlModel implements DatabaseInterface
3535 */
3636 private $ database ;
3737
38- public function __construct (ConfigInterface $ settings = null )
38+ public function __construct (? ConfigInterface $ settings = null )
3939 {
4040 if (empty ($ settings )) {
4141 throw new Exception (\MISSING_CONFIGURATION );
@@ -47,9 +47,9 @@ public function __construct(ConfigInterface $settings = null)
4747 // Turn on track errors
4848 ini_set ('track_errors ' , '1 ' );
4949
50- if (empty ( $ GLOBALS [ 'ez ' . \Pdo] ))
51- $ GLOBALS [ 'ez ' . \Pdo] = $ this ;
52- setInstance ( $ this );
50+ if (!Db:: has ( 'ez ' . \Pdo))
51+ Db:: set ( 'ez ' . \Pdo, $ this ) ;
52+ Db:: set ( ' global ' , $ this );
5353 } // __construct
5454
5555 public function settings ()
@@ -235,7 +235,7 @@ public function catch_error()
235235 * @param boolean $isSelect - return \PDOStatement, if SELECT SQL statement, otherwise int
236236 * @return bool|int|\PDOStatement
237237 */
238- public function query_prepared (string $ query , array $ param = null , $ isSelect = false )
238+ public function query_prepared (string $ query , ? array $ param = null , $ isSelect = false )
239239 {
240240 $ stmt = $ this ->dbh ->prepare ($ query );
241241 $ result = false ;
@@ -349,7 +349,7 @@ private function processResult(string $query, $result = null, bool $isSelect = f
349349 * @param array $param
350350 * @return bool|void
351351 */
352- private function processQuery (string $ query , array $ param = null )
352+ private function processQuery (string $ query , ? array $ param = null )
353353 {
354354 // Query was an insert, delete, update, replace
355355 if (\preg_match ("/^(insert|delete|update|replace|drop|create)\s+/i " , $ query )) {
0 commit comments