2017-01-16 09:31:04 -05:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-01-16 09:31:04 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCP\DB\QueryBuilder;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class provides a builder for sql some functions
|
|
|
|
|
*
|
|
|
|
|
* @since 12.0.0
|
|
|
|
|
*/
|
|
|
|
|
interface IFunctionBuilder {
|
|
|
|
|
/**
|
|
|
|
|
* Calculates the MD5 hash of a given input
|
|
|
|
|
*
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $input The input to be hashed
|
2017-01-16 09:31:04 -05:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 12.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function md5($input): IQueryFunction;
|
2017-01-16 09:31:04 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Combines two input strings
|
|
|
|
|
*
|
2021-12-17 15:21:35 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $x Expressions or literal strings
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction ...$exprs Expressions or literal strings
|
2017-01-16 09:31:04 -05:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 12.0.0
|
|
|
|
|
*/
|
2021-12-17 15:21:35 -05:00
|
|
|
public function concat($x, ...$expr): IQueryFunction;
|
2017-01-16 09:31:04 -05:00
|
|
|
|
2021-12-21 10:18:15 -05:00
|
|
|
/**
|
|
|
|
|
* Returns a string which is the concatenation of all non-NULL values of X
|
|
|
|
|
*
|
|
|
|
|
* Usage examples:
|
|
|
|
|
*
|
|
|
|
|
* groupConcat('column') -- with comma as separator (default separator)
|
|
|
|
|
*
|
|
|
|
|
* groupConcat('column', ';') -- with different separator
|
|
|
|
|
*
|
2022-01-04 02:50:10 -05:00
|
|
|
* @param string|IQueryFunction $expr The expression to group
|
2021-12-21 10:18:15 -05:00
|
|
|
* @param string|null $separator The separator
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
2022-01-03 09:04:05 -05:00
|
|
|
public function groupConcat($expr, ?string $separator = ','): IQueryFunction;
|
2021-12-21 10:18:15 -05:00
|
|
|
|
2017-01-16 09:31:04 -05:00
|
|
|
/**
|
|
|
|
|
* Takes a substring from the input string
|
|
|
|
|
*
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $input The input string
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $start The start of the substring, note that counting starts at 1
|
|
|
|
|
* @param null|ILiteral|IParameter|IQueryFunction $length The length of the substring
|
2017-01-16 09:31:04 -05:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 12.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function substring($input, $start, $length = null): IQueryFunction;
|
2017-04-12 10:09:35 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Takes the sum of all rows in a column
|
|
|
|
|
*
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $field the column to sum
|
2017-04-12 10:09:35 -04:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 12.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function sum($field): IQueryFunction;
|
2017-12-20 09:51:37 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Transforms a string field or value to lower case
|
|
|
|
|
*
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $field
|
2017-12-20 09:51:37 -05:00
|
|
|
* @return IQueryFunction
|
2018-03-06 15:55:04 -05:00
|
|
|
* @since 14.0.0
|
2017-12-20 09:51:37 -05:00
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function lower($field): IQueryFunction;
|
2018-04-10 12:30:43 -04:00
|
|
|
|
|
|
|
|
/**
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number
|
2018-04-10 12:30:43 -04:00
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 14.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function add($x, $y): IQueryFunction;
|
2018-04-10 12:30:43 -04:00
|
|
|
|
|
|
|
|
/**
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number
|
2018-04-10 12:30:43 -04:00
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 14.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function subtract($x, $y): IQueryFunction;
|
2018-06-14 08:32:22 -04:00
|
|
|
|
|
|
|
|
/**
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $count The input to be counted
|
2018-10-19 10:44:28 -04:00
|
|
|
* @param string $alias Alias for the counter
|
2018-06-14 08:32:22 -04:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 14.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function count($count = '', $alias = ''): IQueryFunction;
|
2019-09-04 10:48:02 -04:00
|
|
|
|
2022-03-24 11:17:37 -04:00
|
|
|
/**
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $field The input to be measured
|
|
|
|
|
* @param string $alias Alias for the length
|
|
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function octetLength($field, $alias = ''): IQueryFunction;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $field The input to be measured
|
|
|
|
|
* @param string $alias Alias for the length
|
|
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 24.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function charLength($field, $alias = ''): IQueryFunction;
|
|
|
|
|
|
2019-09-04 10:48:02 -04:00
|
|
|
/**
|
|
|
|
|
* Takes the maximum of all rows in a column
|
|
|
|
|
*
|
2019-11-06 05:38:47 -05:00
|
|
|
* If you want to get the maximum value of multiple columns in the same row, use `greatest` instead
|
|
|
|
|
*
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $field the column to maximum
|
2019-09-04 10:48:02 -04:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function max($field): IQueryFunction;
|
2019-09-04 10:48:02 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Takes the minimum of all rows in a column
|
|
|
|
|
*
|
2019-11-06 05:38:47 -05:00
|
|
|
* If you want to get the minimum value of multiple columns in the same row, use `least` instead
|
|
|
|
|
*
|
2020-11-16 13:17:21 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $field the column to minimum
|
2019-09-04 10:48:02 -04:00
|
|
|
*
|
|
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function min($field): IQueryFunction;
|
2019-11-06 05:38:47 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Takes the maximum of multiple values
|
|
|
|
|
*
|
|
|
|
|
* If you want to get the maximum value of all rows in a column, use `max` instead
|
|
|
|
|
*
|
2020-11-07 08:06:03 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $x
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $y
|
2019-11-06 05:38:47 -05:00
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function greatest($x, $y): IQueryFunction;
|
2019-11-06 05:38:47 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Takes the minimum of multiple values
|
|
|
|
|
*
|
|
|
|
|
* If you want to get the minimum value of all rows in a column, use `min` instead
|
|
|
|
|
*
|
2020-11-07 08:06:03 -05:00
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $x
|
|
|
|
|
* @param string|ILiteral|IParameter|IQueryFunction $y
|
2019-11-06 05:38:47 -05:00
|
|
|
* @return IQueryFunction
|
|
|
|
|
* @since 18.0.0
|
|
|
|
|
*/
|
2020-11-16 13:17:21 -05:00
|
|
|
public function least($x, $y): IQueryFunction;
|
2017-01-16 09:31:04 -05:00
|
|
|
}
|