Skip to content

Commit fe54d07

Browse files
committed
corrections/code clean up
1 parent c99c425 commit fe54d07

File tree

5 files changed

+30
-21
lines changed

5 files changed

+30
-21
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"VARBIT",
2020
"VARCHAR",
2121
"autoload",
22+
"cacert",
2223
"codecov",
2324
"ezmysqli",
2425
"ezpdo",
@@ -30,7 +31,9 @@
3031
"isfile",
3132
"mysqli",
3233
"pgsql",
34+
"phpunit",
3335
"postgresql",
36+
"privatekey",
3437
"repo",
3538
"sqlserver",
3639
"sqlsrv",

lib/DatabaseInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,9 @@ public function disconnect();
9797
* Get connection handle
9898
*/
9999
public function handle();
100+
101+
/**
102+
* Reset connection handle
103+
*/
104+
public function reset();
100105
}

lib/ezFunctions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function setInstance($ezSQL = '') {
313313
function getInstance() {
314314
global $ezInstance;
315315

316-
return $ezInstance;
316+
return ($ezInstance instanceOf DatabaseInterface) ? $ezInstance : null;
317317
}
318318

319319
function clearInstance() {

lib/ezQuery.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function where( ...$whereKeyArray)
391391
return ($where != '1') ? " $whereOrHaving ".$where.' ' : ' ' ;
392392
}
393393

394-
public function selecting($table ='', $columnFields = '*', ...$conditions)
394+
public function selecting(string $table = null, $columnFields = '*', ...$conditions)
395395
{
396396
$getFromTable = $this->fromTable;
397397
$getSelect_result = $this->select_result;
@@ -490,17 +490,17 @@ private function select_sql($table = '', $columnFields = '*', ...$conditions)
490490
return $this->selecting($table, $columnFields, ...$conditions);
491491
}
492492

493-
public function union($table = '', $columnFields = '*', ...$conditions)
493+
public function union(string $table = null, $columnFields = '*', ...$conditions)
494494
{
495495
return 'UNION '.$this->select_sql($table, $columnFields, ...$conditions);
496496
}
497497

498-
public function unionAll($table = '', $columnFields = '*', ...$conditions)
498+
public function unionAll(string $table = null, $columnFields = '*', ...$conditions)
499499
{
500500
return 'UNION ALL '.$this->select_sql($table, $columnFields, ...$conditions);
501501
}
502502

503-
public function create_select($newTable, $fromColumns, $oldTable = null, ...$fromWhere)
503+
public function create_select(string $newTable, $fromColumns, $oldTable = null, ...$fromWhere)
504504
{
505505
if (isset($oldTable))
506506
$this->fromTable = $oldTable;
@@ -517,7 +517,7 @@ public function create_select($newTable, $fromColumns, $oldTable = null, ...$fro
517517
return $this->clearPrepare();
518518
}
519519

520-
public function select_into($newTable, $fromColumns, $oldTable = null, ...$fromWhere)
520+
public function select_into(string $newTable, $fromColumns, $oldTable = null, ...$fromWhere)
521521
{
522522
$this->isInto = true;
523523
if (isset($oldTable))
@@ -534,7 +534,7 @@ public function select_into($newTable, $fromColumns, $oldTable = null, ...$fromW
534534
return $this->clearPrepare();
535535
}
536536

537-
public function update($table = '', $keyAndValue, ...$whereKeys)
537+
public function update(string $table = null, $keyAndValue, ...$whereKeys)
538538
{
539539
if ( ! is_array( $keyAndValue ) || empty($table) ) {
540540
return $this->clearPrepare();
@@ -567,7 +567,7 @@ public function update($table = '', $keyAndValue, ...$whereKeys)
567567
return $this->clearPrepare();
568568
}
569569

570-
public function delete($table = '', ...$whereKeys)
570+
public function delete(string $table = null, ...$whereKeys)
571571
{
572572
if ( empty($table) ) {
573573
return $this->clearPrepare();
@@ -647,17 +647,17 @@ private function _query_insert_replace($table = '', $keyAndValue, $type = '', $e
647647
}
648648
}
649649

650-
public function replace($table = '', $keyAndValue)
650+
public function replace(string $table = null, $keyAndValue)
651651
{
652652
return $this->_query_insert_replace($table, $keyAndValue, 'REPLACE');
653653
}
654654

655-
public function insert($table = '', $keyAndValue)
655+
public function insert(string $table = null, $keyAndValue)
656656
{
657657
return $this->_query_insert_replace($table, $keyAndValue, 'INSERT');
658658
}
659659

660-
public function insert_select($toTable = '', $toColumns = '*', $fromTable = null, $fromColumns = '*', ...$fromWhere)
660+
public function insert_select(string $toTable = null, $toColumns = '*', $fromTable = null, $fromColumns = '*', ...$fromWhere)
661661
{
662662
$putToTable = $this->_query_insert_replace($toTable, $toColumns, 'INSERT', false);
663663
$getFromTable = $this->select_sql($fromTable, $fromColumns, ...$fromWhere);

lib/ezQueryInterface.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function fullJoin(
224224
*
225225
* @return bool|string - false for error
226226
*/
227-
public function union($table = '', $columnFields = '*', ...$conditions);
227+
public function union(string $table = null, $columnFields = '*', ...$conditions);
228228

229229
/**
230230
* Returns an `UNION ALL` SELECT SQL string, given the
@@ -250,7 +250,7 @@ public function union($table = '', $columnFields = '*', ...$conditions);
250250
*
251251
* @return bool|string - false for error
252252
*/
253-
public function unionAll($table = '', $columnFields = '*', ...$conditions);
253+
public function unionAll(string $table = null, $columnFields = '*', ...$conditions);
254254

255255
/**
256256
* Specifies an ordering for the query results.
@@ -332,7 +332,7 @@ public function where( ...$whereKeyArray);
332332
*
333333
* @return mixed result set - see docs for more details, or false for error
334334
*/
335-
public function selecting($table = '', $columnFields = '*', ...$conditions);
335+
public function selecting(string $table = null, $columnFields = '*', ...$conditions);
336336

337337
/**
338338
* Does an create select statement by calling selecting method
@@ -344,7 +344,7 @@ public function selecting($table = '', $columnFields = '*', ...$conditions);
344344
*
345345
* @return mixed bool/result - false for error
346346
*/
347-
public function create_select($newTable, $fromColumns, $oldTable = null, ...$fromWhere);
347+
public function create_select(string $newTable, $fromColumns, $oldTable = null, ...$fromWhere);
348348

349349
/**
350350
* Does an select into statement by calling selecting method
@@ -355,7 +355,7 @@ public function create_select($newTable, $fromColumns, $oldTable = null, ...$fro
355355
*
356356
* @return mixed bool/result - false for error
357357
*/
358-
public function select_into($newTable, $fromColumns, $oldTable = null, ...$fromWhere);
358+
public function select_into(string $newTable, $fromColumns, $oldTable = null, ...$fromWhere);
359359

360360
/**
361361
* Does an update query with an array, by conditional operator array
@@ -365,29 +365,29 @@ public function select_into($newTable, $fromColumns, $oldTable = null, ...$fromW
365365
*
366366
* @return mixed bool/results - false for error
367367
*/
368-
public function update($table = '', $keyAndValue, ...$whereKeys);
368+
public function update(string $table = null, $keyAndValue, ...$whereKeys);
369369

370370
/**
371371
* Helper does the actual delete query with an array
372372
* @return mixed bool/results - false for error
373373
*/
374-
public function delete($table = '', ...$whereKeys);
374+
public function delete(string $table = null, ...$whereKeys);
375375

376376
/**
377377
* Does an replace query with an array
378378
* @param $table, - database table to access
379379
* @param $keyAndValue - table fields, assoc array with key = value (doesn't need escaped)
380380
* @return mixed bool/id of replaced record, or false for error
381381
*/
382-
public function replace($table = '', $keyAndValue);
382+
public function replace(string $table = null, $keyAndValue);
383383

384384
/**
385385
* Does an insert query with an array
386386
* @param $table, - database table to access
387387
* @param $keyAndValue - table fields, assoc array with key = value (doesn't need escaped)
388388
* @return mixed bool/id of inserted record, or false for error
389389
*/
390-
public function insert($table = '', $keyAndValue);
390+
public function insert(string $table = null, $keyAndValue);
391391

392392
/**
393393
* Does an insert into select statement by calling insert method helper then selecting method
@@ -397,7 +397,8 @@ public function insert($table = '', $keyAndValue);
397397
*
398398
* @return mixed bool/id of inserted record, or false for error
399399
*/
400-
public function insert_select($toTable = '', $toColumns = '*', $fromTable = null, $fromColumns = '*', ...$fromWhere);
400+
public function insert_select(
401+
string $toTable = null, $toColumns = '*', $fromTable = null, $fromColumns = '*', ...$fromWhere);
401402

402403
/**
403404
* Creates an database table and columns, by either:

0 commit comments

Comments
 (0)