You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
3.9 KiB

3 years ago
  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 mixed $input The input to be hashed
  36. *
  37. * @return IQueryFunction
  38. * @since 12.0.0
  39. */
  40. public function md5($input);
  41. /**
  42. * Combines two input strings
  43. *
  44. * @param mixed $x The first input string
  45. * @param mixed $y The seccond input string
  46. *
  47. * @return IQueryFunction
  48. * @since 12.0.0
  49. */
  50. public function concat($x, $y);
  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. /**
  63. * Takes the sum of all rows in a column
  64. *
  65. * @param mixed $field the column to sum
  66. *
  67. * @return IQueryFunction
  68. * @since 12.0.0
  69. */
  70. public function sum($field);
  71. /**
  72. * Transforms a string field or value to lower case
  73. *
  74. * @param mixed $field
  75. * @return IQueryFunction
  76. * @since 14.0.0
  77. */
  78. public function lower($field);
  79. /**
  80. * @param mixed $x The first input field or number
  81. * @param mixed $y The second input field or number
  82. * @return IQueryFunction
  83. * @since 14.0.0
  84. */
  85. public function add($x, $y);
  86. /**
  87. * @param mixed $x The first input field or number
  88. * @param mixed $y The second input field or number
  89. * @return IQueryFunction
  90. * @since 14.0.0
  91. */
  92. public function subtract($x, $y);
  93. /**
  94. * @param mixed $count The input to be counted
  95. * @param string $alias Alias for the counter
  96. *
  97. * @return IQueryFunction
  98. * @since 14.0.0
  99. */
  100. public function count($count = '', $alias = '');
  101. /**
  102. * Takes the maximum of all rows in a column
  103. *
  104. * If you want to get the maximum value of multiple columns in the same row, use `greatest` instead
  105. *
  106. * @param mixed $field the column to maximum
  107. *
  108. * @return IQueryFunction
  109. * @since 18.0.0
  110. */
  111. public function max($field);
  112. /**
  113. * Takes the minimum of all rows in a column
  114. *
  115. * If you want to get the minimum value of multiple columns in the same row, use `least` instead
  116. *
  117. * @param mixed $field the column to minimum
  118. *
  119. * @return IQueryFunction
  120. * @since 18.0.0
  121. */
  122. public function min($field);
  123. /**
  124. * Takes the maximum of multiple values
  125. *
  126. * If you want to get the maximum value of all rows in a column, use `max` instead
  127. *
  128. * @param mixed $x the first input field or number
  129. * @param mixed $y the first input field or number
  130. *
  131. * @return IQueryFunction
  132. * @since 18.0.0
  133. */
  134. public function greatest($x, $y);
  135. /**
  136. * Takes the minimum of multiple values
  137. *
  138. * If you want to get the minimum value of all rows in a column, use `min` instead
  139. *
  140. * @param mixed $x the first input field or number
  141. * @param mixed $y the first input field or number
  142. *
  143. * @return IQueryFunction
  144. * @since 18.0.0
  145. */
  146. public function least($x, $y);
  147. }