選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

IFunctionBuilder.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 The first input string
  45. * @param string|ILiteral|IParameter|IQueryFunction $y The seccond input string
  46. *
  47. * @return IQueryFunction
  48. * @since 12.0.0
  49. */
  50. public function concat($x, $y): IQueryFunction;
  51. /**
  52. * Takes a substring from the input string
  53. *
  54. * @param string|ILiteral|IParameter|IQueryFunction $input The input string
  55. * @param string|ILiteral|IParameter|IQueryFunction $start The start of the substring, note that counting starts at 1
  56. * @param null|ILiteral|IParameter|IQueryFunction $length The length of the substring
  57. *
  58. * @return IQueryFunction
  59. * @since 12.0.0
  60. */
  61. public function substring($input, $start, $length = null): IQueryFunction;
  62. /**
  63. * Takes the sum of all rows in a column
  64. *
  65. * @param string|ILiteral|IParameter|IQueryFunction $field the column to sum
  66. *
  67. * @return IQueryFunction
  68. * @since 12.0.0
  69. */
  70. public function sum($field): IQueryFunction;
  71. /**
  72. * Transforms a string field or value to lower case
  73. *
  74. * @param string|ILiteral|IParameter|IQueryFunction $field
  75. * @return IQueryFunction
  76. * @since 14.0.0
  77. */
  78. public function lower($field): IQueryFunction;
  79. /**
  80. * @param string|ILiteral|IParameter|IQueryFunction $x The first input field or number
  81. * @param string|ILiteral|IParameter|IQueryFunction $y The second input field or number
  82. * @return IQueryFunction
  83. * @since 14.0.0
  84. */
  85. 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 subtract($x, $y): IQueryFunction;
  93. /**
  94. * @param string|ILiteral|IParameter|IQueryFunction $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 = ''): IQueryFunction;
  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 string|ILiteral|IParameter|IQueryFunction $field the column to maximum
  107. *
  108. * @return IQueryFunction
  109. * @since 18.0.0
  110. */
  111. public function max($field): IQueryFunction;
  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 string|ILiteral|IParameter|IQueryFunction $field the column to minimum
  118. *
  119. * @return IQueryFunction
  120. * @since 18.0.0
  121. */
  122. public function min($field): IQueryFunction;
  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 string|ILiteral|IParameter|IQueryFunction $x
  129. * @param string|ILiteral|IParameter|IQueryFunction $y
  130. * @return IQueryFunction
  131. * @since 18.0.0
  132. */
  133. public function greatest($x, $y): IQueryFunction;
  134. /**
  135. * Takes the minimum of multiple values
  136. *
  137. * If you want to get the minimum value of all rows in a column, use `min` instead
  138. *
  139. * @param string|ILiteral|IParameter|IQueryFunction $x
  140. * @param string|ILiteral|IParameter|IQueryFunction $y
  141. * @return IQueryFunction
  142. * @since 18.0.0
  143. */
  144. public function least($x, $y): IQueryFunction;
  145. }