@@ -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 ();
0 commit comments