@@ -31,128 +31,128 @@ |
||
| 31 | 31 | * @since 12.0.0 |
| 32 | 32 | */ |
| 33 | 33 | interface IFunctionBuilder { |
| 34 | - /** |
|
| 35 | - * Calculates the MD5 hash of a given input |
|
| 36 | - * |
|
| 37 | - * @param string|ILiteral|IParameter|IQueryFunction $input The input to be hashed |
|
| 38 | - * |
|
| 39 | - * @return IQueryFunction |
|
| 40 | - * @since 12.0.0 |
|
| 41 | - */ |
|
| 42 | - public function md5($input): IQueryFunction; |
|
| 34 | + /** |
|
| 35 | + * Calculates the MD5 hash of a given input |
|
| 36 | + * |
|
| 37 | + * @param string|ILiteral|IParameter|IQueryFunction $input The input to be hashed |
|
| 38 | + * |
|
| 39 | + * @return IQueryFunction |
|
| 40 | + * @since 12.0.0 |
|
| 41 | + */ |
|
| 42 | + public function md5($input): IQueryFunction; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Combines two input strings |
|
| 46 | - * |
|
| 47 | - * @param string|ILiteral|IParameter|IQueryFunction $x The first input string |
|
| 48 | - * @param string|ILiteral|IParameter|IQueryFunction $y The seccond input string |
|
| 49 | - * |
|
| 50 | - * @return IQueryFunction |
|
| 51 | - * @since 12.0.0 |
|
| 52 | - */ |
|
| 53 | - public function concat($x, $y): IQueryFunction; |
|
| 44 | + /** |
|
| 45 | + * Combines two input strings |
|
| 46 | + * |
|
| 47 | + * @param string|ILiteral|IParameter|IQueryFunction $x The first input string |
|
| 48 | + * @param string|ILiteral|IParameter|IQueryFunction $y The seccond input string |
|
| 49 | + * |
|
| 50 | + * @return IQueryFunction |
|
| 51 | + * @since 12.0.0 |
|
| 52 | + */ |
|
| 53 | + public function concat($x, $y): IQueryFunction; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Takes a substring from the input string |
|
| 57 | - * |
|
| 58 | - * @param string|ILiteral|IParameter|IQueryFunction $input The input string |
|
| 59 | - * @param string|ILiteral|IParameter|IQueryFunction $start The start of the substring, note that counting starts at 1 |
|
| 60 | - * @param null|ILiteral|IParameter|IQueryFunction $length The length of the substring |
|
| 61 | - * |
|
| 62 | - * @return IQueryFunction |
|
| 63 | - * @since 12.0.0 |
|
| 64 | - */ |
|
| 65 | - public function substring($input, $start, $length = null): IQueryFunction; |
|
| 55 | + /** |
|
| 56 | + * Takes a substring from the input string |
|
| 57 | + * |
|
| 58 | + * @param string|ILiteral|IParameter|IQueryFunction $input The input string |
|
| 59 | + * @param string|ILiteral|IParameter|IQueryFunction $start The start of the substring, note that counting starts at 1 |
|
| 60 | + * @param null|ILiteral|IParameter|IQueryFunction $length The length of the substring |
|
| 61 | + * |
|
| 62 | + * @return IQueryFunction |
|
| 63 | + * @since 12.0.0 |
|
| 64 | + */ |
|
| 65 | + public function substring($input, $start, $length = null): IQueryFunction; |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Takes the sum of all rows in a column |
|
| 69 | - * |
|
| 70 | - * @param string|ILiteral|IParameter|IQueryFunction $field the column to sum |
|
| 71 | - * |
|
| 72 | - * @return IQueryFunction |
|
| 73 | - * @since 12.0.0 |
|
| 74 | - */ |
|
| 75 | - public function sum($field): IQueryFunction; |
|
| 67 | + /** |
|
| 68 | + * Takes the sum of all rows in a column |
|
| 69 | + * |
|
| 70 | + * @param string|ILiteral|IParameter|IQueryFunction $field the column to sum |
|
| 71 | + * |
|
| 72 | + * @return IQueryFunction |
|
| 73 | + * @since 12.0.0 |
|
| 74 | + */ |
|
| 75 | + public function sum($field): IQueryFunction; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Transforms a string field or value to lower case |
|
| 79 | - * |
|
| 80 | - * @param string|ILiteral|IParameter|IQueryFunction $field |
|
| 81 | - * @return IQueryFunction |
|
| 82 | - * @since 14.0.0 |
|
| 83 | - */ |
|
| 84 | - public function lower($field): IQueryFunction; |
|
| 77 | + /** |
|
| 78 | + * Transforms a string field or value to lower case |
|
| 79 | + * |
|
| 80 | + * @param string|ILiteral|IParameter|IQueryFunction $field |
|
| 81 | + * @return IQueryFunction |
|
| 82 | + * @since 14.0.0 |
|
| 83 | + */ |
|
| 84 | + public function lower($field): IQueryFunction; |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number |
|
| 88 | - * @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number |
|
| 89 | - * @return IQueryFunction |
|
| 90 | - * @since 14.0.0 |
|
| 91 | - */ |
|
| 92 | - public function add($x, $y): IQueryFunction; |
|
| 86 | + /** |
|
| 87 | + * @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number |
|
| 88 | + * @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number |
|
| 89 | + * @return IQueryFunction |
|
| 90 | + * @since 14.0.0 |
|
| 91 | + */ |
|
| 92 | + public function add($x, $y): IQueryFunction; |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number |
|
| 96 | - * @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number |
|
| 97 | - * @return IQueryFunction |
|
| 98 | - * @since 14.0.0 |
|
| 99 | - */ |
|
| 100 | - public function subtract($x, $y): IQueryFunction; |
|
| 94 | + /** |
|
| 95 | + * @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number |
|
| 96 | + * @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number |
|
| 97 | + * @return IQueryFunction |
|
| 98 | + * @since 14.0.0 |
|
| 99 | + */ |
|
| 100 | + public function subtract($x, $y): IQueryFunction; |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * @param string|ILiteral|IParameter|IQueryFunction $count The input to be counted |
|
| 104 | - * @param string $alias Alias for the counter |
|
| 105 | - * |
|
| 106 | - * @return IQueryFunction |
|
| 107 | - * @since 14.0.0 |
|
| 108 | - */ |
|
| 109 | - public function count($count = '', $alias = ''): IQueryFunction; |
|
| 102 | + /** |
|
| 103 | + * @param string|ILiteral|IParameter|IQueryFunction $count The input to be counted |
|
| 104 | + * @param string $alias Alias for the counter |
|
| 105 | + * |
|
| 106 | + * @return IQueryFunction |
|
| 107 | + * @since 14.0.0 |
|
| 108 | + */ |
|
| 109 | + public function count($count = '', $alias = ''): IQueryFunction; |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Takes the maximum of all rows in a column |
|
| 113 | - * |
|
| 114 | - * If you want to get the maximum value of multiple columns in the same row, use `greatest` instead |
|
| 115 | - * |
|
| 116 | - * @param string|ILiteral|IParameter|IQueryFunction $field the column to maximum |
|
| 117 | - * |
|
| 118 | - * @return IQueryFunction |
|
| 119 | - * @since 18.0.0 |
|
| 120 | - */ |
|
| 121 | - public function max($field): IQueryFunction; |
|
| 111 | + /** |
|
| 112 | + * Takes the maximum of all rows in a column |
|
| 113 | + * |
|
| 114 | + * If you want to get the maximum value of multiple columns in the same row, use `greatest` instead |
|
| 115 | + * |
|
| 116 | + * @param string|ILiteral|IParameter|IQueryFunction $field the column to maximum |
|
| 117 | + * |
|
| 118 | + * @return IQueryFunction |
|
| 119 | + * @since 18.0.0 |
|
| 120 | + */ |
|
| 121 | + public function max($field): IQueryFunction; |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Takes the minimum of all rows in a column |
|
| 125 | - * |
|
| 126 | - * If you want to get the minimum value of multiple columns in the same row, use `least` instead |
|
| 127 | - * |
|
| 128 | - * @param string|ILiteral|IParameter|IQueryFunction $field the column to minimum |
|
| 129 | - * |
|
| 130 | - * @return IQueryFunction |
|
| 131 | - * @since 18.0.0 |
|
| 132 | - */ |
|
| 133 | - public function min($field): IQueryFunction; |
|
| 123 | + /** |
|
| 124 | + * Takes the minimum of all rows in a column |
|
| 125 | + * |
|
| 126 | + * If you want to get the minimum value of multiple columns in the same row, use `least` instead |
|
| 127 | + * |
|
| 128 | + * @param string|ILiteral|IParameter|IQueryFunction $field the column to minimum |
|
| 129 | + * |
|
| 130 | + * @return IQueryFunction |
|
| 131 | + * @since 18.0.0 |
|
| 132 | + */ |
|
| 133 | + public function min($field): IQueryFunction; |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Takes the maximum of multiple values |
|
| 137 | - * |
|
| 138 | - * If you want to get the maximum value of all rows in a column, use `max` instead |
|
| 139 | - * |
|
| 140 | - * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 141 | - * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 142 | - * @return IQueryFunction |
|
| 143 | - * @since 18.0.0 |
|
| 144 | - */ |
|
| 145 | - public function greatest($x, $y): IQueryFunction; |
|
| 135 | + /** |
|
| 136 | + * Takes the maximum of multiple values |
|
| 137 | + * |
|
| 138 | + * If you want to get the maximum value of all rows in a column, use `max` instead |
|
| 139 | + * |
|
| 140 | + * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 141 | + * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 142 | + * @return IQueryFunction |
|
| 143 | + * @since 18.0.0 |
|
| 144 | + */ |
|
| 145 | + public function greatest($x, $y): IQueryFunction; |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Takes the minimum of multiple values |
|
| 149 | - * |
|
| 150 | - * If you want to get the minimum value of all rows in a column, use `min` instead |
|
| 151 | - * |
|
| 152 | - * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 153 | - * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 154 | - * @return IQueryFunction |
|
| 155 | - * @since 18.0.0 |
|
| 156 | - */ |
|
| 157 | - public function least($x, $y): IQueryFunction; |
|
| 147 | + /** |
|
| 148 | + * Takes the minimum of multiple values |
|
| 149 | + * |
|
| 150 | + * If you want to get the minimum value of all rows in a column, use `min` instead |
|
| 151 | + * |
|
| 152 | + * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 153 | + * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 154 | + * @return IQueryFunction |
|
| 155 | + * @since 18.0.0 |
|
| 156 | + */ |
|
| 157 | + public function least($x, $y): IQueryFunction; |
|
| 158 | 158 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | use OCP\DB\QueryBuilder\IQueryFunction; |
| 29 | 29 | |
| 30 | 30 | class PgSqlFunctionBuilder extends FunctionBuilder { |
| 31 | - public function concat($x, $y): IQueryFunction { |
|
| 32 | - return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 33 | - } |
|
| 31 | + public function concat($x, $y): IQueryFunction { |
|
| 32 | + return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -29,6 +29,6 @@ |
||
| 29 | 29 | |
| 30 | 30 | class PgSqlFunctionBuilder extends FunctionBuilder { |
| 31 | 31 | public function concat($x, $y): IQueryFunction { |
| 32 | - return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 32 | + return new QueryFunction('('.$this->helper->quoteColumnName($x).' || '.$this->helper->quoteColumnName($y).')'); |
|
| 33 | 33 | } |
| 34 | 34 | } |
@@ -29,47 +29,47 @@ |
||
| 29 | 29 | use OCP\DB\QueryBuilder\IQueryFunction; |
| 30 | 30 | |
| 31 | 31 | class OCIFunctionBuilder extends FunctionBuilder { |
| 32 | - public function md5($input): IQueryFunction { |
|
| 33 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 34 | - } |
|
| 32 | + public function md5($input): IQueryFunction { |
|
| 33 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * As per https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions060.htm |
|
| 38 | - * Oracle uses the first value to cast the rest or the values. So when the |
|
| 39 | - * first value is a literal, plain value or column, instead of doing the |
|
| 40 | - * math, it will cast the expression to int and continue with a "0". So when |
|
| 41 | - * the second parameter is a function or column, we have to put that as |
|
| 42 | - * first parameter. |
|
| 43 | - * |
|
| 44 | - * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 45 | - * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 46 | - * @return IQueryFunction |
|
| 47 | - */ |
|
| 48 | - public function greatest($x, $y): IQueryFunction { |
|
| 49 | - if (is_string($y) || $y instanceof IQueryFunction) { |
|
| 50 | - return parent::greatest($y, $x); |
|
| 51 | - } |
|
| 36 | + /** |
|
| 37 | + * As per https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions060.htm |
|
| 38 | + * Oracle uses the first value to cast the rest or the values. So when the |
|
| 39 | + * first value is a literal, plain value or column, instead of doing the |
|
| 40 | + * math, it will cast the expression to int and continue with a "0". So when |
|
| 41 | + * the second parameter is a function or column, we have to put that as |
|
| 42 | + * first parameter. |
|
| 43 | + * |
|
| 44 | + * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 45 | + * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 46 | + * @return IQueryFunction |
|
| 47 | + */ |
|
| 48 | + public function greatest($x, $y): IQueryFunction { |
|
| 49 | + if (is_string($y) || $y instanceof IQueryFunction) { |
|
| 50 | + return parent::greatest($y, $x); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return parent::greatest($x, $y); |
|
| 54 | - } |
|
| 53 | + return parent::greatest($x, $y); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * As per https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions060.htm |
|
| 58 | - * Oracle uses the first value to cast the rest or the values. So when the |
|
| 59 | - * first value is a literal, plain value or column, instead of doing the |
|
| 60 | - * math, it will cast the expression to int and continue with a "0". So when |
|
| 61 | - * the second parameter is a function or column, we have to put that as |
|
| 62 | - * first parameter. |
|
| 63 | - * |
|
| 64 | - * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 65 | - * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 66 | - * @return IQueryFunction |
|
| 67 | - */ |
|
| 68 | - public function least($x, $y): IQueryFunction { |
|
| 69 | - if (is_string($y) || $y instanceof IQueryFunction) { |
|
| 70 | - return parent::least($y, $x); |
|
| 71 | - } |
|
| 56 | + /** |
|
| 57 | + * As per https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions060.htm |
|
| 58 | + * Oracle uses the first value to cast the rest or the values. So when the |
|
| 59 | + * first value is a literal, plain value or column, instead of doing the |
|
| 60 | + * math, it will cast the expression to int and continue with a "0". So when |
|
| 61 | + * the second parameter is a function or column, we have to put that as |
|
| 62 | + * first parameter. |
|
| 63 | + * |
|
| 64 | + * @param string|ILiteral|IParameter|IQueryFunction $x |
|
| 65 | + * @param string|ILiteral|IParameter|IQueryFunction $y |
|
| 66 | + * @return IQueryFunction |
|
| 67 | + */ |
|
| 68 | + public function least($x, $y): IQueryFunction { |
|
| 69 | + if (is_string($y) || $y instanceof IQueryFunction) { |
|
| 70 | + return parent::least($y, $x); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return parent::least($x, $y); |
|
| 74 | - } |
|
| 73 | + return parent::least($x, $y); |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | class OCIFunctionBuilder extends FunctionBuilder { |
| 32 | 32 | public function md5($input): IQueryFunction { |
| 33 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 33 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw('.$this->helper->quoteColumnName($input).')))'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -30,69 +30,69 @@ |
||
| 30 | 30 | use OCP\DB\QueryBuilder\IQueryFunction; |
| 31 | 31 | |
| 32 | 32 | class FunctionBuilder implements IFunctionBuilder { |
| 33 | - /** @var QuoteHelper */ |
|
| 34 | - protected $helper; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * ExpressionBuilder constructor. |
|
| 38 | - * |
|
| 39 | - * @param QuoteHelper $helper |
|
| 40 | - */ |
|
| 41 | - public function __construct(QuoteHelper $helper) { |
|
| 42 | - $this->helper = $helper; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - public function md5($input): IQueryFunction { |
|
| 46 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function concat($x, $y): IQueryFunction { |
|
| 50 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function substring($input, $start, $length = null): IQueryFunction { |
|
| 54 | - if ($length) { |
|
| 55 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 56 | - } else { |
|
| 57 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function sum($field): IQueryFunction { |
|
| 62 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function lower($field): IQueryFunction { |
|
| 66 | - return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function add($x, $y): IQueryFunction { |
|
| 70 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function subtract($x, $y): IQueryFunction { |
|
| 74 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function count($count = '', $alias = ''): IQueryFunction { |
|
| 78 | - $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; |
|
| 79 | - $quotedName = $count === '' ? '*' : $this->helper->quoteColumnName($count); |
|
| 80 | - return new QueryFunction('COUNT(' . $quotedName . ')' . $alias); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function max($field): IQueryFunction { |
|
| 84 | - return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function min($field): IQueryFunction { |
|
| 88 | - return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - public function greatest($x, $y): IQueryFunction { |
|
| 92 | - return new QueryFunction('GREATEST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function least($x, $y): IQueryFunction { |
|
| 96 | - return new QueryFunction('LEAST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 97 | - } |
|
| 33 | + /** @var QuoteHelper */ |
|
| 34 | + protected $helper; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * ExpressionBuilder constructor. |
|
| 38 | + * |
|
| 39 | + * @param QuoteHelper $helper |
|
| 40 | + */ |
|
| 41 | + public function __construct(QuoteHelper $helper) { |
|
| 42 | + $this->helper = $helper; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + public function md5($input): IQueryFunction { |
|
| 46 | + return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function concat($x, $y): IQueryFunction { |
|
| 50 | + return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function substring($input, $start, $length = null): IQueryFunction { |
|
| 54 | + if ($length) { |
|
| 55 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 56 | + } else { |
|
| 57 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function sum($field): IQueryFunction { |
|
| 62 | + return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function lower($field): IQueryFunction { |
|
| 66 | + return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function add($x, $y): IQueryFunction { |
|
| 70 | + return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + public function subtract($x, $y): IQueryFunction { |
|
| 74 | + return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function count($count = '', $alias = ''): IQueryFunction { |
|
| 78 | + $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; |
|
| 79 | + $quotedName = $count === '' ? '*' : $this->helper->quoteColumnName($count); |
|
| 80 | + return new QueryFunction('COUNT(' . $quotedName . ')' . $alias); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + public function max($field): IQueryFunction { |
|
| 84 | + return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function min($field): IQueryFunction { |
|
| 88 | + return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + public function greatest($x, $y): IQueryFunction { |
|
| 92 | + return new QueryFunction('GREATEST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function least($x, $y): IQueryFunction { |
|
| 96 | + return new QueryFunction('LEAST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -43,56 +43,56 @@ |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function md5($input): IQueryFunction { |
| 46 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 46 | + return new QueryFunction('MD5('.$this->helper->quoteColumnName($input).')'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function concat($x, $y): IQueryFunction { |
| 50 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 50 | + return new QueryFunction('CONCAT('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function substring($input, $start, $length = null): IQueryFunction { |
| 54 | 54 | if ($length) { |
| 55 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 55 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).', '.$this->helper->quoteColumnName($length).')'); |
|
| 56 | 56 | } else { |
| 57 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 57 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).')'); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function sum($field): IQueryFunction { |
| 62 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 62 | + return new QueryFunction('SUM('.$this->helper->quoteColumnName($field).')'); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function lower($field): IQueryFunction { |
| 66 | - return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 66 | + return new QueryFunction('LOWER('.$this->helper->quoteColumnName($field).')'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function add($x, $y): IQueryFunction { |
| 70 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); |
|
| 70 | + return new QueryFunction($this->helper->quoteColumnName($x).' + '.$this->helper->quoteColumnName($y)); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function subtract($x, $y): IQueryFunction { |
| 74 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); |
|
| 74 | + return new QueryFunction($this->helper->quoteColumnName($x).' - '.$this->helper->quoteColumnName($y)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function count($count = '', $alias = ''): IQueryFunction { |
| 78 | - $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; |
|
| 78 | + $alias = $alias ? (' AS '.$this->helper->quoteColumnName($alias)) : ''; |
|
| 79 | 79 | $quotedName = $count === '' ? '*' : $this->helper->quoteColumnName($count); |
| 80 | - return new QueryFunction('COUNT(' . $quotedName . ')' . $alias); |
|
| 80 | + return new QueryFunction('COUNT('.$quotedName.')'.$alias); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function max($field): IQueryFunction { |
| 84 | - return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 84 | + return new QueryFunction('MAX('.$this->helper->quoteColumnName($field).')'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function min($field): IQueryFunction { |
| 88 | - return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 88 | + return new QueryFunction('MIN('.$this->helper->quoteColumnName($field).')'); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function greatest($x, $y): IQueryFunction { |
| 92 | - return new QueryFunction('GREATEST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 92 | + return new QueryFunction('GREATEST('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function least($x, $y): IQueryFunction { |
| 96 | - return new QueryFunction('LEAST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 96 | + return new QueryFunction('LEAST('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 97 | 97 | } |
| 98 | 98 | } |
@@ -28,15 +28,15 @@ |
||
| 28 | 28 | use OCP\DB\QueryBuilder\IQueryFunction; |
| 29 | 29 | |
| 30 | 30 | class SqliteFunctionBuilder extends FunctionBuilder { |
| 31 | - public function concat($x, $y): IQueryFunction { |
|
| 32 | - return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 33 | - } |
|
| 31 | + public function concat($x, $y): IQueryFunction { |
|
| 32 | + return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function greatest($x, $y): IQueryFunction { |
|
| 36 | - return new QueryFunction('MAX(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 37 | - } |
|
| 35 | + public function greatest($x, $y): IQueryFunction { |
|
| 36 | + return new QueryFunction('MAX(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function least($x, $y): IQueryFunction { |
|
| 40 | - return new QueryFunction('MIN(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 41 | - } |
|
| 39 | + public function least($x, $y): IQueryFunction { |
|
| 40 | + return new QueryFunction('MIN(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -29,14 +29,14 @@ |
||
| 29 | 29 | |
| 30 | 30 | class SqliteFunctionBuilder extends FunctionBuilder { |
| 31 | 31 | public function concat($x, $y): IQueryFunction { |
| 32 | - return new QueryFunction('(' . $this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 32 | + return new QueryFunction('('.$this->helper->quoteColumnName($x).' || '.$this->helper->quoteColumnName($y).')'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function greatest($x, $y): IQueryFunction { |
| 36 | - return new QueryFunction('MAX(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 36 | + return new QueryFunction('MAX('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function least($x, $y): IQueryFunction { |
| 40 | - return new QueryFunction('MIN(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 40 | + return new QueryFunction('MIN('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 41 | 41 | } |
| 42 | 42 | } |