Skip to content

Commit 6881e33

Browse files
committed
some doc-block updates
1 parent 3d766a3 commit 6881e33

File tree

2 files changed

+108
-12
lines changed

2 files changed

+108
-12
lines changed

lib/ezFunctions.php

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,39 @@ function cleanInput($string)
310310
return ezQuery::clean($string);
311311
}
312312

313+
/**
314+
* Returns an SQL string or result set, given the
315+
* - table, column fields, conditions or conditional array.
316+
*
317+
* In the following format:
318+
* ```js
319+
* select(
320+
* table,
321+
* columns,
322+
* (innerJoin(), leftJoin(), rightJoin(), fullJoin()), // alias of joining(inner|left|right|full, leftTable, rightTable, leftColumn, rightColumn, equal condition),
323+
* where( eq( columns, values, _AND ), like( columns, _d ) ),
324+
* groupBy( columns ),
325+
* having( between( columns, values1, values2 ) ),
326+
* orderBy( columns, desc ),
327+
* limit( numberOfRecords, offset ),
328+
* union(table, columnFields, conditions), // Returns an select SQL string with `UNION`
329+
* unionAll(table, columnFields, conditions) // Returns an select SQL string with `UNION ALL`
330+
*);
331+
* ```
332+
* @param $table, - database table to access
333+
* @param $columnFields, - table columns, string or array
334+
* @param mixed ...$conditions - of the following parameters:
335+
*
336+
* @param $joins, - join clause (type, left table, right table, left column, right column, condition = EQ)
337+
* @param $whereKey, - where clause ( comparison(x, y, and) )
338+
* @param $groupBy, - grouping over clause the results
339+
* @param $having, - having clause ( comparison(x, y, and) )
340+
* @param $orderby, - ordering by clause for the query
341+
* @param $limit, - limit clause the number of records
342+
* @param $union/$unionAll - union clause combine the result sets and removes duplicate rows/does not remove
343+
*
344+
* @return mixed result set - see docs for more details, or false for error
345+
*/
313346
function select($table = '', $columns = '*', ...$args)
314347
{
315348
$ezQuery = \getInstance();
@@ -318,6 +351,15 @@ function select($table = '', $columns = '*', ...$args)
318351
: false;
319352
}
320353

354+
/**
355+
* Does an select into statement by calling selecting method
356+
* @param $newTable, - new database table to be created
357+
* @param $fromColumns - the columns from old database table
358+
* @param $oldTable - old database table
359+
* @param $fromWhere, - where clause ( array(x, =, y, and, extra) ) or ( "x = y and extra" )
360+
*
361+
* @return mixed bool/result - false for error
362+
*/
321363
function select_into($table, $columns = '*', $old = null, ...$args)
322364
{
323365
$ezQuery = \getInstance();
@@ -342,14 +384,68 @@ function create_select($table, $from, $old = null, ...$args)
342384
: false;
343385
}
344386

345-
function where(...$args)
387+
/**
388+
* Returns an `WHERE` **sql clause** string.
389+
*
390+
* format:
391+
* `where( comparison(x, y, and) )`
392+
*
393+
* example:
394+
* `where( eq(key, value ), like('key', '_%?');`
395+
*
396+
* @param array $whereConditions - In the following format:
397+
*```js
398+
* eq('key/Field/Column', $value, _AND), // combine next expression
399+
* neq('key/Field/Column', $value, _OR), // will combine next expression if
400+
* ne('key/Field/Column', $value), // the default is _AND so will combine next expression
401+
* lt('key/Field/Column', $value)
402+
* lte('key/Field/Column', $value)
403+
* gt('key/Field/Column', $value)
404+
* gte('key/Field/Column', $value)
405+
* isNull('key/Field/Column')
406+
* isNotNull('key/Field/Column')
407+
* like('key/Field/Column', '_%')
408+
* notLike('key/Field/Column', '_%')
409+
* in('key/Field/Column', $values)
410+
* notIn('key/Field/Column', $values)
411+
* between('key/Field/Column', $value, $value2)
412+
* notBetween('key/Field/Column', $value, $value2)
413+
*```
414+
* @return mixed bool/string - WHERE sql statement, or false on error
415+
*/
416+
function where(...$whereConditions)
346417
{
347418
$ezQuery = \getInstance();
348419
return ($ezQuery instanceof DatabaseInterface)
349-
? $ezQuery->where(...$args)
420+
? $ezQuery->where(...$whereConditions)
350421
: false;
351422
}
352423

424+
/**
425+
* Adds WHERE grouping to the conditions
426+
*
427+
* format:
428+
* `grouping( comparison(x, y, and) )`
429+
*
430+
* example:
431+
* `grouping( eq(key, value, combiner ), eq(key, value, combiner ) );`
432+
*
433+
* @param array $whereConditions - In the following format:
434+
*```js
435+
* eq('key/Field/Column', $value, _AND), // combine next expression
436+
* neq('key/Field/Column', $value, _OR), // will combine next expression again
437+
* ne('key/Field/Column', $value), // the default is _AND so will combine next expression
438+
* lt('key/Field/Column', $value)
439+
* lte('key/Field/Column', $value)
440+
* gt('key/Field/Column', $value)
441+
* gte('key/Field/Column', $value)
442+
* isNull('key/Field/Column')
443+
* isNotNull('key/Field/Column')
444+
* like('key/Field/Column', '_%')
445+
* notLike('key/Field/Column', '_%')
446+
*```
447+
* @return array modified conditions
448+
*/
353449
function grouping(...$args)
354450
{
355451
$ezQuery = \getInstance();

lib/ezQueryInterface.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function limit($numberOf, $offset = null);
304304
* `grouping( eq(key, value, combiner ), eq(key, value, combiner ) );`
305305
*
306306
* @param array $whereConditions - In the following format:
307-
*
307+
*```js
308308
* eq('key/Field/Column', $value, _AND), // combine next expression
309309
* neq('key/Field/Column', $value, _OR), // will combine next expression again
310310
* ne('key/Field/Column', $value), // the default is _AND so will combine next expression
@@ -316,7 +316,7 @@ public function limit($numberOf, $offset = null);
316316
* isNotNull('key/Field/Column')
317317
* like('key/Field/Column', '_%')
318318
* notLike('key/Field/Column', '_%')
319-
*
319+
*```
320320
* @return array modified conditions
321321
*/
322322
public function grouping(...$whereConditions);
@@ -331,9 +331,9 @@ public function grouping(...$whereConditions);
331331
* `where( eq(key, value ), like('key', '_%?');`
332332
*
333333
* @param array $whereConditions - In the following format:
334-
*
334+
*```js
335335
* eq('key/Field/Column', $value, _AND), // combine next expression
336-
* neq('key/Field/Column', $value, _OR), // will combine next expression again
336+
* neq('key/Field/Column', $value, _OR), // will combine next expression if
337337
* ne('key/Field/Column', $value), // the default is _AND so will combine next expression
338338
* lt('key/Field/Column', $value)
339339
* lte('key/Field/Column', $value)
@@ -347,22 +347,22 @@ public function grouping(...$whereConditions);
347347
* notIn('key/Field/Column', $values)
348348
* between('key/Field/Column', $value, $value2)
349349
* notBetween('key/Field/Column', $value, $value2)
350-
*
350+
*```
351351
* @return mixed bool/string - WHERE SQL statement, or false on error
352352
*/
353353
public function where(...$whereConditions);
354354

355+
355356
/**
356357
* Returns an SQL string or result set, given the
357358
* - table, column fields, conditions or conditional array.
358359
*
359360
* In the following format:
360-
* ```
361-
* selecting(
361+
* ```js
362+
* select(
362363
* table,
363364
* columns,
364-
* // innerJoin(), leftJoin(), rightJoin(), fullJoin() alias of
365-
* joining(inner|left|right|full, leftTable, rightTable, leftColumn, rightColumn, equal condition),
365+
* (innerJoin(), leftJoin(), rightJoin(), fullJoin()), // alias of joining(inner|left|right|full, leftTable, rightTable, leftColumn, rightColumn, equal condition),
366366
* where( eq( columns, values, _AND ), like( columns, _d ) ),
367367
* groupBy( columns ),
368368
* having( between( columns, values1, values2 ) ),
@@ -374,7 +374,7 @@ public function where(...$whereConditions);
374374
* ```
375375
* @param $table, - database table to access
376376
* @param $columnFields, - table columns, string or array
377-
* @param mixed $conditions - of the following parameters:
377+
* @param mixed ...$conditions - of the following parameters:
378378
*
379379
* @param $joins, - join clause (type, left table, right table, left column, right column, condition = EQ)
380380
* @param $whereKey, - where clause ( comparison(x, y, and) )

0 commit comments

Comments
 (0)