123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace OC\DB\QueryBuilder\FunctionBuilder;
- use OC\DB\QueryBuilder\QueryFunction;
- use OCP\DB\QueryBuilder\ILiteral;
- use OCP\DB\QueryBuilder\IParameter;
- use OCP\DB\QueryBuilder\IQueryFunction;
- class OCIFunctionBuilder extends FunctionBuilder {
- public function md5($input): IQueryFunction {
- return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))');
- }
-
- public function greatest($x, $y): IQueryFunction {
- if (is_string($y) || $y instanceof IQueryFunction) {
- return parent::greatest($y, $x);
- }
- return parent::greatest($x, $y);
- }
-
- public function least($x, $y): IQueryFunction {
- if (is_string($y) || $y instanceof IQueryFunction) {
- return parent::least($y, $x);
- }
- return parent::least($x, $y);
- }
- public function concat($x, ...$expr): IQueryFunction {
- $args = func_get_args();
- $list = [];
- foreach ($args as $item) {
- $list[] = $this->helper->quoteColumnName($item);
- }
- return new QueryFunction(sprintf('(%s)', implode(' || ', $list)));
- }
- public function groupConcat($expr, ?string $separator = ','): IQueryFunction {
- $orderByClause = ' WITHIN GROUP(ORDER BY NULL)';
- if (is_null($separator)) {
- return new QueryFunction('LISTAGG(' . $this->helper->quoteColumnName($expr) . ')' . $orderByClause);
- }
- $separator = $this->connection->quote($separator);
- return new QueryFunction('LISTAGG(' . $this->helper->quoteColumnName($expr) . ', ' . $separator . ')' . $orderByClause);
- }
- public function octetLength($field, $alias = ''): IQueryFunction {
- $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
- $quotedName = $this->helper->quoteColumnName($field);
- return new QueryFunction('LENGTHB(' . $quotedName . ')' . $alias);
- }
- public function charLength($field, $alias = ''): IQueryFunction {
- $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : '';
- $quotedName = $this->helper->quoteColumnName($field);
- return new QueryFunction('LENGTH(' . $quotedName . ')' . $alias);
- }
- }
|