|
11 | 11 |
|
12 | 12 | namespace CodeIgniter\Database\SQLSRV; |
13 | 13 |
|
14 | | -use Closure; |
15 | 14 | use CodeIgniter\Database\BaseBuilder; |
16 | 15 | use CodeIgniter\Database\Exceptions\DatabaseException; |
17 | 16 | use CodeIgniter\Database\Exceptions\DataException; |
@@ -516,73 +515,6 @@ protected function compileSelect($selectOverride = false): string |
516 | 515 | return $sql; |
517 | 516 | } |
518 | 517 |
|
519 | | - /** |
520 | | - * WHERE, HAVING |
521 | | - * |
522 | | - * @param mixed $key |
523 | | - * @param mixed $value |
524 | | - * |
525 | | - * @return $this |
526 | | - */ |
527 | | - protected function whereHaving(string $qbKey, $key, $value = null, string $type = 'AND ', ?bool $escape = null) |
528 | | - { |
529 | | - if (! is_array($key)) { |
530 | | - $key = [$key => $value]; |
531 | | - } |
532 | | - |
533 | | - // If the escape value was not set will base it on the global setting |
534 | | - if (! is_bool($escape)) { |
535 | | - $escape = $this->db->protectIdentifiers; |
536 | | - } |
537 | | - |
538 | | - foreach ($key as $k => $v) { |
539 | | - $prefix = empty($this->{$qbKey}) ? $this->groupGetType('') : $this->groupGetType($type); |
540 | | - |
541 | | - if ($v !== null) { |
542 | | - $op = $this->getOperator($k, true); |
543 | | - |
544 | | - if (! empty($op)) { |
545 | | - $k = trim($k); |
546 | | - |
547 | | - end($op); |
548 | | - |
549 | | - $op = trim(current($op)); |
550 | | - |
551 | | - if (substr($k, -1 * strlen($op)) === $op) { |
552 | | - $k = rtrim(strrev(preg_replace(strrev('/' . $op . '/'), strrev(''), strrev($k), 1))); |
553 | | - } |
554 | | - } |
555 | | - |
556 | | - $bind = $this->setBind($k, $v, $escape); |
557 | | - |
558 | | - if (empty($op)) { |
559 | | - $k .= ' ='; |
560 | | - } else { |
561 | | - $k .= " {$op}"; |
562 | | - } |
563 | | - |
564 | | - if ($v instanceof Closure) { |
565 | | - $builder = $this->cleanClone(); |
566 | | - $v = '(' . str_replace("\n", ' ', $v($builder)->getCompiledSelect()) . ')'; |
567 | | - } else { |
568 | | - $v = " :{$bind}:"; |
569 | | - } |
570 | | - } elseif (! $this->hasOperator($k) && $qbKey !== 'QBHaving') { |
571 | | - // value appears not to have been set, assign the test to IS NULL |
572 | | - $k .= ' IS NULL'; |
573 | | - } elseif (preg_match('/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE)) { |
574 | | - $k = substr($k, 0, $match[0][1]) . ($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL'); |
575 | | - } |
576 | | - |
577 | | - $this->{$qbKey}[] = [ |
578 | | - 'condition' => $prefix . $k . $v, |
579 | | - 'escape' => $escape, |
580 | | - ]; |
581 | | - } |
582 | | - |
583 | | - return $this; |
584 | | - } |
585 | | - |
586 | 518 | /** |
587 | 519 | * Compiles the select statement based on the other functions called |
588 | 520 | * and runs the query |
|
0 commit comments