Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

IFunctionBuilder.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCP\DB\QueryBuilder;
  26. /**
  27. * This class provides a builder for sql some functions
  28. *
  29. * @since 12.0.0
  30. */
  31. interface IFunctionBuilder {
  32. /**
  33. * Calculates the MD5 hash of a given input
  34. *
  35. * @param string|ILiteral|IParameter|IQueryFunction $input The input to be hashed
  36. *
  37. * @return IQueryFunction
  38. * @since 12.0.0
  39. */
  40. public function md5($input): IQueryFunction;
  41. /**
  42. * Combines two input strings
  43. *
  44. * @param string|ILiteral|IParameter|IQueryFunction $x Expressions or literal strings
  45. * @param string|ILiteral|IParameter|IQueryFunction ...$exprs Expressions or literal strings
  46. *
  47. * @return IQueryFunction
  48. * @since 12.0.0
  49. */
  50. public function concat($x, ...$expr): IQueryFunction;
  51. /**
  52. * Returns a string which is the concatenation of all non-NULL values of X
  53. *
  54. * Usage examples:
  55. *
  56. * groupConcat('column') -- with comma as separator (default separator)
  57. *
  58. * groupConcat('column', ';') -- with different separator
  59. *
  60. * @param string|IQueryFunction $expr The expression to group
  61. * @param string|null $separator The separator
  62. * @return IQueryFunction
  63. * @since 24.0.0
  64. */
  65. public function groupConcat($expr, ?string $separator = ','): IQueryFunction;
  66. /**
  67. * Takes a substring from the input string
  68. *
  69. * @param string|ILiteral|IParameter|IQueryFunction $input The input string
  70. * @param string|ILiteral|IParameter|IQueryFunction $start The start of the substring, note that counting starts at 1
  71. * @param null|ILiteral|IParameter|IQueryFunction $length The length of the substring
  72. *
  73. * @return IQueryFunction
  74. * @since 12.0.0
  75. */
  76. public function substring($input, $start, $length = null): IQueryFunction;
  77. /**
  78. * Takes the sum of all rows in a column
  79. *
  80. * @param string|ILiteral|IParameter|IQueryFunction $field the column to sum
  81. *
  82. * @return IQueryFunction
  83. * @since 12.0.0
  84. */
  85. public function sum($field): IQueryFunction;
  86. /**
  87. * Transforms a string field or value to lower case
  88. *
  89. * @param string|ILiteral|IParameter|IQueryFunction $field
  90. * @return IQueryFunction
  91. * @since 14.0.0
  92. */
  93. public function lower($field): 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 add($x, $y): IQueryFunction;
  101. /**
  102. * @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number
  103. * @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number
  104. * @return IQueryFunction
  105. * @since 14.0.0
  106. */
  107. public function subtract($x, $y): IQueryFunction;
  108. /**
  109. * @param string|ILiteral|IParameter|IQueryFunction $count The input to be counted
  110. * @param string $alias Alias for the counter
  111. *
  112. * @return IQueryFunction
  113. * @since 14.0.0
  114. */
  115. public function count($count = '', $alias = ''): IQueryFunction;
  116. /**
  117. * Takes the maximum of all rows in a column
  118. *
  119. * If you want to get the maximum value of multiple columns in the same row, use `greatest` instead
  120. *
  121. * @param string|ILiteral|IParameter|IQueryFunction $field the column to maximum
  122. *
  123. * @return IQueryFunction
  124. * @since 18.0.0
  125. */
  126. public function max($field): IQueryFunction;
  127. /**
  128. * Takes the minimum of all rows in a column
  129. *
  130. * If you want to get the minimum value of multiple columns in the same row, use `least` instead
  131. *
  132. * @param string|ILiteral|IParameter|IQueryFunction $field the column to minimum
  133. *
  134. * @return IQueryFunction
  135. * @since 18.0.0
  136. */
  137. public function min($field): IQueryFunction;
  138. /**
  139. * Takes the maximum of multiple values
  140. *
  141. * If you want to get the maximum value of all rows in a column, use `max` instead
  142. *
  143. * @param string|ILiteral|IParameter|IQueryFunction $x
  144. * @param string|ILiteral|IParameter|IQueryFunction $y
  145. * @return IQueryFunction
  146. * @since 18.0.0
  147. */
  148. public function greatest($x, $y): IQueryFunction;
  149. /**
  150. * Takes the minimum of multiple values
  151. *
  152. * If you want to get the minimum value of all rows in a column, use `min` instead
  153. *
  154. * @param string|ILiteral|IParameter|IQueryFunction $x
  155. * @param string|ILiteral|IParameter|IQueryFunction $y
  156. * @return IQueryFunction
  157. * @since 18.0.0
  158. */
  159. public function least($x, $y): IQueryFunction;
  160. }