@@ -26,35 +26,35 @@ |
||
| 26 | 26 | use OCP\DB\QueryBuilder\IFunctionBuilder; |
| 27 | 27 | |
| 28 | 28 | class FunctionBuilder implements IFunctionBuilder { |
| 29 | - /** @var QuoteHelper */ |
|
| 30 | - protected $helper; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * ExpressionBuilder constructor. |
|
| 34 | - * |
|
| 35 | - * @param QuoteHelper $helper |
|
| 36 | - */ |
|
| 37 | - public function __construct(QuoteHelper $helper) { |
|
| 38 | - $this->helper = $helper; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function md5($input) { |
|
| 42 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - public function concat($x, $y) { |
|
| 46 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function substring($input, $start, $length = null) { |
|
| 50 | - if ($length) { |
|
| 51 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 52 | - } else { |
|
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function sum($field) { |
|
| 58 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 59 | - } |
|
| 29 | + /** @var QuoteHelper */ |
|
| 30 | + protected $helper; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * ExpressionBuilder constructor. |
|
| 34 | + * |
|
| 35 | + * @param QuoteHelper $helper |
|
| 36 | + */ |
|
| 37 | + public function __construct(QuoteHelper $helper) { |
|
| 38 | + $this->helper = $helper; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function md5($input) { |
|
| 42 | + return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + public function concat($x, $y) { |
|
| 46 | + return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function substring($input, $start, $length = null) { |
|
| 50 | + if ($length) { |
|
| 51 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 52 | + } else { |
|
| 53 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function sum($field) { |
|
| 58 | + return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -39,22 +39,22 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function md5($input) { |
| 42 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 42 | + return new QueryFunction('MD5('.$this->helper->quoteColumnName($input).')'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function concat($x, $y) { |
| 46 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 46 | + return new QueryFunction('CONCAT('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function substring($input, $start, $length = null) { |
| 50 | 50 | if ($length) { |
| 51 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 51 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).', '.$this->helper->quoteColumnName($length).')'); |
|
| 52 | 52 | } else { |
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 53 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).')'); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function sum($field) { |
| 58 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
| 58 | + return new QueryFunction('SUM('.$this->helper->quoteColumnName($field).')'); |
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -27,46 +27,46 @@ |
||
| 27 | 27 | * @since 12.0.0 |
| 28 | 28 | */ |
| 29 | 29 | interface IFunctionBuilder { |
| 30 | - /** |
|
| 31 | - * Calculates the MD5 hash of a given input |
|
| 32 | - * |
|
| 33 | - * @param mixed $input The input to be hashed |
|
| 34 | - * |
|
| 35 | - * @return IQueryFunction |
|
| 36 | - * @since 12.0.0 |
|
| 37 | - */ |
|
| 38 | - public function md5($input); |
|
| 30 | + /** |
|
| 31 | + * Calculates the MD5 hash of a given input |
|
| 32 | + * |
|
| 33 | + * @param mixed $input The input to be hashed |
|
| 34 | + * |
|
| 35 | + * @return IQueryFunction |
|
| 36 | + * @since 12.0.0 |
|
| 37 | + */ |
|
| 38 | + public function md5($input); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Combines two input strings |
|
| 42 | - * |
|
| 43 | - * @param mixed $x The first input string |
|
| 44 | - * @param mixed $y The seccond input string |
|
| 45 | - * |
|
| 46 | - * @return IQueryFunction |
|
| 47 | - * @since 12.0.0 |
|
| 48 | - */ |
|
| 49 | - public function concat($x, $y); |
|
| 40 | + /** |
|
| 41 | + * Combines two input strings |
|
| 42 | + * |
|
| 43 | + * @param mixed $x The first input string |
|
| 44 | + * @param mixed $y The seccond input string |
|
| 45 | + * |
|
| 46 | + * @return IQueryFunction |
|
| 47 | + * @since 12.0.0 |
|
| 48 | + */ |
|
| 49 | + public function concat($x, $y); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Takes a substring from the input string |
|
| 53 | - * |
|
| 54 | - * @param mixed $input The input string |
|
| 55 | - * @param mixed $start The start of the substring, note that counting starts at 1 |
|
| 56 | - * @param mixed $length The length of the substring |
|
| 57 | - * |
|
| 58 | - * @return IQueryFunction |
|
| 59 | - * @since 12.0.0 |
|
| 60 | - */ |
|
| 61 | - public function substring($input, $start, $length = null); |
|
| 51 | + /** |
|
| 52 | + * Takes a substring from the input string |
|
| 53 | + * |
|
| 54 | + * @param mixed $input The input string |
|
| 55 | + * @param mixed $start The start of the substring, note that counting starts at 1 |
|
| 56 | + * @param mixed $length The length of the substring |
|
| 57 | + * |
|
| 58 | + * @return IQueryFunction |
|
| 59 | + * @since 12.0.0 |
|
| 60 | + */ |
|
| 61 | + public function substring($input, $start, $length = null); |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Takes the sum of all rows in a column |
|
| 65 | - * |
|
| 66 | - * @param mixed $field the column to sum |
|
| 67 | - * |
|
| 68 | - * @return IQueryFunction |
|
| 69 | - * @since 12.0.0 |
|
| 70 | - */ |
|
| 71 | - public function sum($field); |
|
| 63 | + /** |
|
| 64 | + * Takes the sum of all rows in a column |
|
| 65 | + * |
|
| 66 | + * @param mixed $field the column to sum |
|
| 67 | + * |
|
| 68 | + * @return IQueryFunction |
|
| 69 | + * @since 12.0.0 |
|
| 70 | + */ |
|
| 71 | + public function sum($field); |
|
| 72 | 72 | } |