Skip to content

Commit a9fcf87

Browse files
committed
misc doc-blocks and code coverage updates
1 parent 13dfca2 commit a9fcf87

File tree

5 files changed

+68
-34
lines changed

5 files changed

+68
-34
lines changed

lib/Database.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Database
1818
private static $factory = null;
1919
private static $instances = [];
2020

21+
// @codeCoverageIgnoreStart
2122
private function __construct()
2223
{
2324
}
@@ -27,6 +28,7 @@ private function __clone()
2728
public function __wakeup()
2829
{
2930
}
31+
// @codeCoverageIgnoreEnd
3032

3133
/**
3234
* Initialize and connect a vendor database.

lib/ezFunctions.php

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -965,14 +965,32 @@ function set_prefix(string $append = '')
965965

966966
/**
967967
* Does an `select into` statement by calling `select` method
968-
* @param $newTable, - new database table to be created
969-
* @param $fromColumns - the columns from old database table
970-
* @param $oldTable - old database table
971-
* @param $fromWhereConditions, - where clause `eq(x, y, _AND), another clause - same as array(x, =, y, and, extra) `
972-
*
973-
* @return mixed|object bool/result - false for error
968+
* @param string $newTable, - new database table to be created
969+
* @param mixed $fromColumns - the columns from old database table
970+
* @param string $oldTable - old database table
971+
* @param mixed $fromWhereConditions, - where clause `eq(x, y, _AND), another clause - same as array(x, =, y, and, extra)`
972+
* - In the following format:
973+
*```js
974+
* eq('key/Field/Column', $value, _AND), // combine next expression
975+
* neq('key/Field/Column', $value, _OR), // will combine next expression if
976+
* ne('key/Field/Column', $value), // the default is _AND so will combine next expression
977+
* lt('key/Field/Column', $value)
978+
* lte('key/Field/Column', $value)
979+
* gt('key/Field/Column', $value)
980+
* gte('key/Field/Column', $value)
981+
* isNull('key/Field/Column')
982+
* isNotNull('key/Field/Column')
983+
* like('key/Field/Column', '_%')
984+
* notLike('key/Field/Column', '_%')
985+
* in('key/Field/Column', $values)
986+
* notIn('key/Field/Column', $values)
987+
* between('key/Field/Column', $value, $value2)
988+
* notBetween('key/Field/Column', $value, $value2)
989+
*```
990+
* @return mixed bool/result - false for error
991+
* @codeCoverageIgnore
974992
*/
975-
function select_into($newTable, $fromColumns = '*', $oldTable = null, ...$fromWhereConditions)
993+
function select_into(string $newTable, $fromColumns = '*', string $oldTable = null, ...$fromWhereConditions)
976994
{
977995
$ezQuery = getInstance();
978996
return ($ezQuery instanceof DatabaseInterface)
@@ -1096,15 +1114,15 @@ function grouping(...$conditions)
10961114
* having( between( 'columns', values1, values2 ) ),
10971115
* orderBy( 'columns', 'desc' );
10981116
*</code>
1099-
* @param mixed $groupBy The grouping expression.
1117+
* @param string|array $column The grouping expression.
11001118
*
11011119
* @return string - GROUP BY SQL statement, or false on error
11021120
*/
1103-
function groupBy($groupBy)
1121+
function groupBy($column)
11041122
{
11051123
$ezQuery = getInstance();
11061124
return ($ezQuery instanceof DatabaseInterface)
1107-
? $ezQuery->groupBy($groupBy)
1125+
? $ezQuery->groupBy($column)
11081126
: false;
11091127
}
11101128

@@ -1364,16 +1382,16 @@ function unionAll($table = '', $columnFields = '*', ...$conditions)
13641382

13651383
/**
13661384
* Specifies an ordering for the query results.
1367-
* @param string $orderBy - The column.
1385+
* @param string|array $column - Which columns to use for ordering.
13681386
* @param string $order - The ordering direction, either `ASC`|`DESC`.
13691387
*
13701388
* @return string - ORDER BY SQL statement, or false on error
13711389
*/
1372-
function orderBy($orderBy, $order)
1390+
function orderBy($column, $order)
13731391
{
13741392
$ezQuery = getInstance();
13751393
return ($ezQuery instanceof DatabaseInterface)
1376-
? $ezQuery->orderBy($orderBy, $order)
1394+
? $ezQuery->orderBy($column, $order)
13771395
: false;
13781396
}
13791397

@@ -1394,6 +1412,9 @@ function limit($numberOf, $offset = null)
13941412
: false;
13951413
}
13961414

1415+
/**
1416+
* @codeCoverageIgnore
1417+
*/
13971418
function ezFunctions()
13981419
{
13991420
return true;

lib/ezQuery.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ public static function to_string($arrays, $separation = ',')
111111
return $columns;
112112
}
113113

114-
public function groupBy($groupBy)
114+
public function groupBy($column)
115115
{
116-
if (empty($groupBy)) {
116+
if (empty($column)) {
117117
return false;
118118
}
119119

120-
$columns = $this->to_string($groupBy);
120+
$columns = $this->to_string($column);
121121

122122
return 'GROUP BY ' . $columns;
123123
}
@@ -262,13 +262,13 @@ private function joining(
262262
return ' ' . $type . ' JOIN ' . $rightTable . ' AS ' . $tableAs . ' ' . $onCondition;
263263
}
264264

265-
public function orderBy($orderBy, $order)
265+
public function orderBy($column, $order)
266266
{
267-
if (empty($orderBy)) {
267+
if (empty($column)) {
268268
return false;
269269
}
270270

271-
$columns = $this->to_string($orderBy);
271+
$columns = $this->to_string($column);
272272
$by = \strtoupper($order);
273273
$order = (\in_array($by, array('ASC', 'DESC'))) ? $by : 'ASC';
274274

@@ -593,6 +593,9 @@ public function create_select(string $newTable, $fromColumns = '*', $oldTable =
593593
return $this->clearPrepare();
594594
}
595595

596+
/**
597+
* @codeCoverageIgnore
598+
*/
596599
public function select_into(string $newTable, $fromColumns = '*', $oldTable = null, ...$fromWhereConditions)
597600
{
598601
$this->isInto = true;
@@ -602,7 +605,7 @@ public function select_into(string $newTable, $fromColumns = '*', $oldTable = nu
602605
return $this->clearPrepare();
603606

604607
$newTableFromTable = $this->select_sql($newTable, $fromColumns, ...$fromWhereConditions);
605-
if (is_string($newTableFromTable))
608+
if (\is_string($newTableFromTable))
606609
return (($this->isPrepareOn()) && !empty($this->prepareValues()))
607610
? $this->query($newTableFromTable, true)
608611
: $this->query($newTableFromTable);

lib/ezQueryInterface.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function prepareOff();
5050
* having( between( 'columns', values1, values2 ) ),
5151
* orderBy( 'columns', 'desc' );
5252
*</code>
53-
* @param mixed $groupBy The grouping expression.
53+
* @param string|array $column The grouping expression.
5454
*
5555
* @return string - GROUP BY SQL statement, or false on error
5656
*/
57-
public function groupBy($groupBy);
57+
public function groupBy($column);
5858

5959
/**
6060
* Specifies a `restriction` over the groups of the query.
@@ -275,12 +275,12 @@ public function unionAll(string $table = null, $columnFields = '*', ...$conditio
275275

276276
/**
277277
* Specifies an ordering for the query results.
278-
* @param string $orderBy - The column.
278+
* @param string|array $column - Which columns to use for ordering.
279279
* @param string $order - The ordering direction, either `ASC`|`DESC`.
280280
*
281281
* @return string - ORDER BY SQL statement, or false on error
282282
*/
283-
public function orderBy($orderBy, $order);
283+
public function orderBy($column, $order);
284284

285285
/**
286286
* Specifies records from one or more tables in a database and
@@ -452,10 +452,10 @@ function inserting(array $keyValue);
452452
/**
453453
* Does an `create select` statement by calling `select` method
454454
*
455-
* @param $newTable, - new database table to be created
456-
* @param $fromColumns - the columns from old database table
457-
* @param $oldTable - old database table
458-
* @param $fromWhereConditions, - where clause `eq(x, y, _AND), another clause - same as array(x, =, y, and, extra)`
455+
* @param string $newTable, - new database table to be created
456+
* @param string|array $fromColumns - the columns from old database table
457+
* @param string $oldTable - old database table
458+
* @param array $fromWhereConditions, - where clause `eq(x, y, _AND), another clause - same as array(x, =, y, and, extra)`
459459
* - In the following format:
460460
*```js
461461
* eq('key/Field/Column', $value, _AND), // combine next expression
@@ -480,10 +480,10 @@ public function create_select(string $newTable, $fromColumns = '*', $oldTable =
480480

481481
/**
482482
* Does an `select into` statement by calling `select` method
483-
* @param $newTable, - new database table to be created
484-
* @param $fromColumns - the columns from old database table
485-
* @param $oldTable - old database table
486-
* @param $fromWhereConditions, - where clause `eq(x, y, _AND), another clause - same as array(x, =, y, and, extra)`
483+
* @param string $newTable, - new database table to be created
484+
* @param mixed $fromColumns - the columns from old database table
485+
* @param string $oldTable - old database table
486+
* @param mixed $fromWhereConditions, - where clause `eq(x, y, _AND), another clause - same as array(x, =, y, and, extra)`
487487
* - In the following format:
488488
*```js
489489
* eq('key/Field/Column', $value, _AND), // combine next expression
@@ -504,7 +504,7 @@ public function create_select(string $newTable, $fromColumns = '*', $oldTable =
504504
*```
505505
* @return mixed bool/result - false for error
506506
*/
507-
public function select_into(string $newTable, $fromColumns = '*', $oldTable = null, ...$fromWhereConditions);
507+
public function select_into(string $newTable, $fromColumns = '*', string $oldTable = null, ...$fromWhereConditions);
508508

509509
/**
510510
* Does an `update` query with an array, by conditional operator array

tests/mysqli/mysqliTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
dropping,
2626
altering,
2727
get_results,
28+
groupBy,
2829
limit,
2930
orderBy,
3031
replacing,
@@ -605,7 +606,14 @@ public function testSelectAndCreateTable()
605606
])
606607
);
607608

608-
$result = $this->object->select('users', 'id, tel_num, email', where(eq('user_name ', 'walker')), orderBy('id', 'ASC'), limit(1));
609+
$result = $this->object->select(
610+
'users',
611+
'id, tel_num, email',
612+
where(eq('user_name ', 'walker')),
613+
groupBy('id'),
614+
orderBy('id', 'ASC'),
615+
limit(1)
616+
);
609617

610618
$this->object->debugOn();
611619
$this->expectOutputRegex('/[123456]/');

0 commit comments

Comments
 (0)