How to use notContains method of child class

Best Atoum code snippet using child.notContains

Where.php

Source:Where.php Github

copy

Full Screen

...94 '-not-end-with' => 'notEndWith',95 'NotEndWith' => 'notEndWith',96 '-contains' => 'contains',97 'Contains' => 'contains',98 '-not-contains' => 'notContains',99 'NotContains' => 'notContains',100 '-like' => 'like',101 'Like' => 'like',102 '-not-like' => 'notLike',103 'NotLike' => 'notLike',104 '-equal' => 'equal',105 'Equal' => 'equal',106 '-not-equal' => 'notEqual',107 'NotEqual' => 'notEqual',108 '-lower-than-equal' => 'lowerThanEqual',109 'LowerThanEqual' => 'lowerThanEqual',110 '-not-lower-than-equal' => 'notLowerThanEqual',111 'NotLowerThanEqual' => 'notLowerThanEqual',112 '-lower-than' => 'lowerThan',113 'LowerThan' => 'lowerThan',114 '-not-lower-than' => 'notLowerThan',115 'NotLowerThan' => 'notLowerThan',116 '-greater-than-equal' => 'greaterThanEqual',117 'GreaterThanEqual' => 'greaterThanEqual',118 '-not-greater-than-equal' => 'notGreaterThanEqual',119 'NotGreaterThanEqual' => 'notGreaterThanEqual',120 '-greater-than' => 'greaterThan',121 'GreaterThan' => 'greaterThan',122 '-not-greater-than' => 'notGreaterThan',123 'NotGreaterThan' => 'notGreaterThan',124 '-between' => 'between',125 'Between' => 'between',126 '-not-between' => 'notBetween',127 'NotBetween' => 'notBetween',128 );129 foreach ($fields as $key => $value) {130 if (is_numeric($key)) {131 unset($fields[$key]);132 $fields[$value] = array();133 }134 }135 foreach ($values as $key => $value) {136 preg_match_all($re, $key, $matches, PREG_SET_ORDER, 0);137 if (empty($matches)) {138 $field = $this->unifingColumn($key);139 // standard field140 if (!empty($fields)) {141 if (array_key_exists($field, $fields)) {142 if (array_key_exists($field, $fields) && is_array($fields[$field]) && array_key_exists('field', $fields[$field])) {143 $field = $fields[$field]['field'];144 }145 if (is_array($value)) {146 if (array_key_exists("from", $value) && array_key_exists("to", $value)) {147 $this->greaterThanEqual($field, $value["from"]);148 $this->lowerThanEqual($field, $value["to"]);149 } else if (array_key_exists("from", $value)) {150 $this->greaterThanEqual($field, $value["from"]);151 } elseif (array_key_exists("to", $value)) {152 $this->lowerThanEqual($field, $value["to"]);153 } else {154 $this->in($field, $value);155 }156 } else {157 $this->equal($field, $value);158 }159 continue;160 } else {161 continue;162 }163 } else {164 if (is_array($value)) {165 if (array_key_exists("from", $value) && array_key_exists("to", $value)) {166 $this->greaterThanEqual($field, $value["from"]);167 $this->lowerThanEqual($field, $value["to"]);168 } else if (array_key_exists("from", $value)) {169 $this->greaterThanEqual($field, $value["from"]);170 } elseif (array_key_exists("to", $value)) {171 $this->lowerThanEqual($field, $value["to"]);172 } else {173 $this->in($field, $value);174 }175 } else {176 $this->equal($field, $value);177 }178 continue;179 }180 }181 $field = $this->unifingColumn($matches[0][1]);182 $operation = $operations[$matches[0][2]];183 if (!empty($fields)) {184 if (!array_key_exists($field, $fields)) {185 continue;186 }187 }188 $operationsAllowed = array(189 'in',190 'notIn',191 'isNull',192 'isNotNull',193 'startWith',194 'notStartWith',195 'endWith',196 'notEndWith',197 'contains',198 'notContains',199 'like',200 'notLike',201 'equal',202 'notEqual',203 'lowerThanEqual',204 'notLowerThanEqual',205 'lowerThan',206 'notLowerThan',207 'greaterThanEqual',208 'notGreaterThanEqual',209 'greaterThan',210 'notGreaterThan',211 'between',212 'notBetween',213 );214 $operationsExcluded = array();215 $fieldValue = $field;216 if (array_key_exists($field, $fields) && is_array($fields[$field])) {217 if (array_key_exists('field', $fields[$field])) {218 $fieldValue = $fields[$field]['field'];219 }220 if (array_key_exists('operations', $fields[$field])) {221 $operationsAllowed = $fields[$field]['operations'];222 }223 if (array_key_exists('excluded', $fields[$field])) {224 $operationsExcluded = $fields[$field]['excluded'];225 }226 }227 if (in_array($operation, $operationsExcluded)) {228 continue;229 }230 if (!in_array($operation, $operationsAllowed)) {231 continue;232 }233 switch($operation) {234 case 'in':235 $this->in($fieldValue, $value);236 break;237 case 'notIn':238 $this->notIn($fieldValue, $value);239 break;240 case 'isNull':241 $this->isNull($fieldValue);242 break;243 case 'isNotNull':244 $this->isNotNull($fieldValue);245 break;246 case 'startWith':247 $this->startWith($fieldValue, $value);248 break;249 case 'notStartWith':250 $this->notStartWith($fieldValue, $value);251 break;252 case 'endWith':253 $this->endWith($fieldValue, $value);254 break;255 case 'notEndWith':256 $this->notEndWith($fieldValue, $value);257 break;258 case 'contains':259 $this->contains($fieldValue, $value);260 break;261 case 'notContains':262 $this->notContains($fieldValue, $value);263 break;264 case 'like':265 $this->like($fieldValue, $value);266 break;267 case 'notLike':268 $this->notLike($fieldValue, $value);269 break;270 case 'equal':271 $this->equal($fieldValue, $value);272 break;273 case 'notEqual':274 $this->notEqual($fieldValue, $value);275 break;276 case 'lowerThanEqual':277 $this->lowerThanEqual($fieldValue, $value);278 break;279 case 'notLowerThanEqual':280 $this->notLowerThanEqual($fieldValue, $value);281 break;282 case 'lowerThan':283 $this->lowerThan($fieldValue, $value);284 break;285 case 'notLowerThan':286 $this->notLowerThan($fieldValue, $value);287 break;288 case 'greaterThanEqual':289 $this->greaterThanEqual($fieldValue, $value);290 break;291 case 'notGreaterThanEqual':292 $this->notGreaterThanEqual($fieldValue, $value);293 break;294 case 'greaterThan':295 $this->greaterThan($fieldValue, $value);296 break;297 case 'notGreaterThan':298 $this->notGreaterThan($fieldValue, $value);299 break;300 case 'between':301 if (is_string($value)) {302 $value = explode(',', $value);303 $this->between($fieldValue, $value[0], $value[1]);304 } else {305 if (array_key_exists('from', $value) && array_key_exists('to', $value)) {306 $this->between($fieldValue, $value['from'], $value['to']);307 }308 }309 break;310 case 'notBetween':311 if (is_string($value)) {312 $value = explode(',', $value);313 $this->notBetween($fieldValue, $value[0], $value[1]);314 } else {315 if (array_key_exists('from', $value) && array_key_exists('to', $value)) {316 $this->notBetween($fieldValue, $value['from'], $value['to']);317 }318 }319 break;320 }321 }322 }323 private function unifingColumn(string $name)324 {325 $name = explode("-", $name);326 foreach ($name as $k => $value) {327 if ($k == 0) {328 continue;329 }330 $name[$k] = ucfirst($value);331 }332 return implode('', $name);333 }334 /**335 * Method allow add condition base on type of value. For example if336 * conditions is array then 'in()' statement is added. Below are some337 * example.338 *339 * array(1,2) - in(1,2)340 * 1 - in(1)341 *342 * array(343 * 'from' => 1, - 'between 1 and 4'344 * 'to' => 4,345 * )346 *347 * Default operator is 'in' you can change this with param 'operator'.348 * Operator can be in, contains.349 *350 * @param string $column351 * @param mixed $conditions352 * @param array $params353 * - operator354 *355 * @return $this356 */357 public function conditions($column, $conditions, array $params = array())358 {359 $params['operator'] = !isset($params['operator']) ? 'in' : $params['operator'];360 $value = array();361 // Przypadek w którym struktura definiuje operator, w pozostałych362 // przypadkach staram się odczytać operator363 if (is_array($conditions)) {364 if (array_key_exists('from', $conditions) || array_key_exists('to', $conditions)) {365 if (array_key_exists('from', $conditions) && array_key_exists('to', $conditions)) {366 $this->between($column, $conditions['from'], $conditions['to']);367 } elseif (array_key_exists('from', $conditions)) {368 $this->greaterThanEqual($column, $conditions['from']);369 } elseif (array_key_exists('to', $conditions)) {370 $this->lowerThanEqual($column, $conditions['to']);371 }372 return $this;373 }374 }375 if (376 is_numeric($conditions)377 || is_string($conditions)378 || is_null($conditions)379 ) {380 $value[] = $conditions;381 }elseif(is_array($conditions)){382 // A -> array(1,2,3,4)383 // B -> array(384 // 'id' => 1,385 // )386 // C array(387 // 'from' => 1,388 // 'to' => 1,389 // )390 // D array(391 // array(392 // 'id' => 1,393 // ),394 // array(395 // 'id' => 2,396 // ),397 // ...398 // )399 $isvector = 1;400 foreach (array_keys($conditions) as $key) {401 if (!is_numeric($key)) {402 $isvector = 0;403 break;404 }405 }406 if ($isvector) {407 foreach ($conditions as $key => $v) {408 if (is_numeric($v) || is_string($v)) {409 $value[] = $v;410 }elseif(is_array($v)){411 if (isset($v['id'])) {412 if (is_numeric($v['id']) || is_string($v['id'])) {413 $value[] = $v['id'];414 }415 }416 }417 }418 }else{419 if (isset($conditions['id'])) {420 if (is_numeric($conditions['id']) || is_string($conditions['id'])) {421 $value[] = $conditions['id'];422 }423 }424 }425 }426 switch ($params['operator']) {427 case 'in':428 $this->in($column, $value);429 break;430 case 'contains':431 // Robimy nawias ze wszystkimi ORAMI432 $this->brackets(function($where) use ($value, $column){433 $where->or();434 foreach ($value as $v) {435 $where->contains($column, $v);436 }437 });438 break;439 // case 'equal':440 // // Robimy nawias ze wszystkimi ORAMI441 // $this->brackets(function($where) use ($value, $column){442 // $where->or();443 // foreach ($value as $v) {444 // $where->equal($column, $v);445 // }446 // });447 // break;448 default:449 throw new \InvalidArgumentException("Unsupported operator {$params['operator']}.");450 }451 return $this;452 }453 /**454 * Add in() statement to where. There are few type of methods to call.455 *456 *457 * ```php458 * $rows = (new Select($this->getAdapter('bookshop')))459 * ->from('users', 'u')460 * ->column('u.id')461 * ->column('u.firstName')462 * ->column('u.lastName')463 * ->in('u.id', array(11, 12, 13, 14, 15))464 * ->order('id asc')465 * ->fetch()466 * ;467 *468 * // There is no need to check if array has values. If not 1=2 is place469 * // in place of in()470 * $rows = (new Select($this->getAdapter('bookshop')))471 * ->from('users', 'u')472 * ->column('u.id')473 * ->column('u.firstName')474 * ->column('u.lastName')475 * ->in('u.id', array())476 * ->order('id asc')477 * ->fetch()478 * ;479 *480 * // Other sub query can be use.481 * $sub = (new Select())482 * ->from('users')483 * ->column('id')484 * ->in('u.id', array(11, 12, 13, 14, 15, 'test'))485 * ;486 *487 * $rows = (new Select($this->getAdapter('bookshop')))488 * ->from('users', 'u')489 * ->column('u.id')490 * ->column('u.firstName')491 * ->column('u.lastName')492 * ->in('u.id', $sub)493 * ->order('id asc')494 * ->fetch()495 * ;496 * ```497 */498 public function in($column, $value)499 {500 $child = new stdClass();501 $child->type = 'in';502 $child->column = $column;503 $child->value = $value;504 $this->pointer->childs[] = $child;505 return $this;506 }507 /**508 * Add 'not in()' statement to where. It works like 'in()' but add 'not'.509 *510 * ```php511 *512 * $rows = (new Select($this->getAdapter('bookshop')))513 * ->from('users', 'u')514 * ->column('u.id')515 * ->column('u.firstName')516 * ->column('u.lastName')517 * ->notIn('u.id', array(1, 2, 3, 4, 5))518 * ->order('id asc')519 * ->setLimit(5)520 * ->fetch()521 * ;522 *523 * // Other sub query can be use.524 * $sub = (new Select())525 * ->from('users')526 * ->column('id')527 * ->in('u.id', array(1, 2, 3, 4, 5, 'test'))528 * ;529 *530 * $rows = (new Select($this->getAdapter('bookshop')))531 * ->from('users', 'u')532 * ->column('u.id')533 * ->column('u.firstName')534 * ->column('u.lastName')535 * ->notIn('u.id', $sub)536 * ->setLimit(5)537 * ->order('id asc')538 * ->fetch()539 * ;540 * ```541 *542 */543 public function notIn($column, $value)544 {545 $child = new stdClass();546 $child->type = 'notIn';547 $child->column = $column;548 $child->value = $value;549 $this->pointer->childs[] = $child;550 return $this;551 }552 /**553 * Add 'is null' statement to where.554 *555 * ```php556 * $rows = (new Select($this->getAdapter('bookshop')))557 * ->from('users', 'u')558 * ->column('u.id')559 * ->column('u.firstName')560 * ->column('u.lastName')561 * ->column('u.countryId')562 * ->isNull('u.countryId')563 * ->order('id asc')564 * ->setLimit(10)565 * ->fetch()566 * ;567 * ```568 */569 public function isNull($column)570 {571 $child = new stdClass();572 $child->type = 'isNull';573 $child->column = $column;574 $child->value = null;575 $this->pointer->childs[] = $child;576 return $this;577 }578 public function isNotNull($column)579 {580 $child = new stdClass();581 $child->type = 'isNotNull';582 $child->column = $column;583 $child->value = null;584 $this->pointer->childs[] = $child;585 return $this;586 }587 /**588 * Add like "%value" to where statement.589 *590 * ```php591 * $rows = (new Select($this->getAdapter('bookshop')))592 * ->from('users', 'u')593 * ->column('u.id')594 * ->column('u.countryId')595 * ->column('u.firstName')596 * ->column('u.lastName')597 * ->isNotNull('u.countryId')598 * ->startWith('u.firstName', 'Ali')599 * ->order('id asc')600 * ->setLimit(2)601 * ->fetch()602 * ;603 *604 * $rows = (new Select($this->getAdapter('bookshop')))605 * ->from('users', 'u')606 * ->column('u.id')607 * ->column('u.countryId')608 * ->column('u.firstName')609 * ->column('u.lastName')610 * ->isNotNull('u.countryId')611 * ->startWith('u.firstName', new Expr('"Aliz"'))612 * ->order('id asc')613 * ->setLimit(2)614 * ->fetch()615 * ;616 * ```617 *618 */619 public function startWith($column, $value)620 {621 $child = new stdClass();622 $child->type = 'startWith';623 $child->column = $column;624 $child->value = $value;625 $this->pointer->childs[] = $child;626 return $this;627 }628 public function notStartWith($column, $value)629 {630 $child = new stdClass();631 $child->type = 'notStartWith';632 $child->column = $column;633 $child->value = $value;634 $this->pointer->childs[] = $child;635 return $this;636 }637 /**638 * Add %value end with statement to where.639 *640 * ```php641 * $rows = (new Select($this->getAdapter('bookshop')))642 * ->from('users', 'u')643 * ->column('u.id')644 * ->column('u.firstName')645 * ->endWith('u.firstName', 'trée')646 * ->order('id asc')647 * ->setLimit(2)648 * ->fetch()649 * ;650 *651 * $rows = (new Select($this->getAdapter('bookshop')))652 * ->from('users', 'u')653 * ->column('u.id')654 * ->column('u.firstName')655 * ->endWith('u.firstName', new Expr('"trée"'))656 * ->order('id asc')657 * ->setLimit(2)658 * ->fetch()659 * ;660 * ```661 */662 public function endWith($column, $value)663 {664 $child = new stdClass();665 $child->type = 'endWith';666 $child->column = $column;667 $child->value = $value;668 $this->pointer->childs[] = $child;669 return $this;670 }671 public function notEndWith($column, $value)672 {673 $child = new stdClass();674 $child->type = 'notEndWith';675 $child->column = $column;676 $child->value = $value;677 $this->pointer->childs[] = $child;678 return $this;679 }680 /**681 * Add 'like %value%' statement too where.682 *683 * ```php684 * $rows = (new Select($this->getAdapter('bookshop')))685 * ->from('users', 'u')686 * ->column('u.id')687 * ->column('u.firstName')688 * ->contains('u.firstName', 'ébec')689 * ->order('id asc')690 * ->setLimit(2)691 * ->fetch()692 * ;693 *694 * $rows = (new Select($this->getAdapter('bookshop')))695 * ->from('users', 'u')696 * ->column('u.id')697 * ->column('u.firstName')698 * ->contains('u.firstName', new Expr('"ébec"'))699 * ->order('id asc')700 * ->setLimit(2)701 * ->fetch()702 * ;703 * ```704 *705 */706 public function contains($column, $value)707 {708 $child = new stdClass();709 $child->type = 'contains';710 $child->column = $column;711 $child->value = $value;712 $this->pointer->childs[] = $child;713 return $this;714 }715 public function notContains($column, $value)716 {717 $child = new stdClass();718 $child->type = 'notContains';719 $child->column = $column;720 $child->value = $value;721 $this->pointer->childs[] = $child;722 return $this;723 }724 /**725 * Add 'like value' statement to where.726 *727 * ```php728 * $rows = (new Select($this->getAdapter('bookshop')))729 * ->from('users', 'u')730 * ->column('u.id')731 * ->column('u.firstName')732 * ->contains('u.firstName', 'No%l%a')733 * ->order('id asc')734 * ->setLimit(2)735 * ->fetch()736 * ;737 *738 * $rows = (new Select($this->getAdapter('bookshop')))739 * ->from('users', 'u')740 * ->column('u.id')741 * ->column('u.firstName')742 * ->contains('u.firstName', new Expr('"No%l%a"'))743 * ->order('id asc')744 * ->setLimit(2)745 * ->fetch()746 * ;747 * ```748 */749 public function like($column, $value)750 {751 $child = new stdClass();752 $child->type = 'like';753 $child->column = $column;754 $child->value = $value;755 $this->pointer->childs[] = $child;756 return $this;757 }758 public function notLike($column, $value)759 {760 $child = new stdClass();761 $child->type = 'notLike';762 $child->column = $column;763 $child->value = $value;764 $this->pointer->childs[] = $child;765 return $this;766 }767 public function equal($column, $value)768 {769 $child = new stdClass();770 $child->type = 'equal';771 $child->column = $column;772 $child->value = $value;773 $this->pointer->childs[] = $child;774 return $this;775 }776 public function notEqual($column, $value)777 {778 $child = new stdClass();779 $child->type = 'notEqual';780 $child->column = $column;781 $child->value = $value;782 $this->pointer->childs[] = $child;783 return $this;784 }785 public function lowerThan($column, $value)786 {787 $child = new stdClass();788 $child->type = 'lowerThan';789 $child->column = $column;790 $child->value = $value;791 $this->pointer->childs[] = $child;792 return $this;793 }794 public function notLowerThan($column, $value)795 {796 $child = new stdClass();797 $child->type = 'notLowerThan';798 $child->column = $column;799 $child->value = $value;800 $this->pointer->childs[] = $child;801 return $this;802 }803 public function lowerThanEqual($column, $value)804 {805 $child = new stdClass();806 $child->type = 'lowerThanEqual';807 $child->column = $column;808 $child->value = $value;809 $this->pointer->childs[] = $child;810 return $this;811 }812 public function notLowerThanEqual($column, $value)813 {814 $child = new stdClass();815 $child->type = 'notLowerThanEqual';816 $child->column = $column;817 $child->value = $value;818 $this->pointer->childs[] = $child;819 return $this;820 }821 public function greaterThan($column, $value)822 {823 $child = new stdClass();824 $child->type = 'greaterThan';825 $child->column = $column;826 $child->value = $value;827 $this->pointer->childs[] = $child;828 return $this;829 }830 public function notGreaterThan($column, $value)831 {832 $child = new stdClass();833 $child->type = 'notGreaterThan';834 $child->column = $column;835 $child->value = $value;836 $this->pointer->childs[] = $child;837 return $this;838 }839 public function greaterThanEqual($column, $value)840 {841 $child = new stdClass();842 $child->type = 'greaterThanEqual';843 $child->column = $column;844 $child->value = $value;845 $this->pointer->childs[] = $child;846 return $this;847 }848 public function notGreaterThanEqual($column, $value)849 {850 $child = new stdClass();851 $child->type = 'notGreaterThanEqual';852 $child->column = $column;853 $child->value = $value;854 $this->pointer->childs[] = $child;855 return $this;856 }857 public function expr($expr)858 {859 $child = new stdClass();860 $child->type = 'expr';861 $child->column = null;862 $child->value = $expr;863 $this->pointer->childs[] = $child;864 return $this;865 }866 public function exists($value)867 {868 $child = new stdClass();869 $child->type = 'exists';870 $child->column = null;871 $child->value = $value;872 $this->pointer->childs[] = $child;873 return $this;874 }875 public function notExists($value)876 {877 $child = new stdClass();878 $child->type = 'notExists';879 $child->column = null;880 $child->value = $value;881 $this->pointer->childs[] = $child;882 return $this;883 }884 public function between($column, $begin, $end)885 {886 $child = new stdClass();887 $child->type = 'between';888 $child->column = $column;889 $child->value = array($begin, $end);890 $this->pointer->childs[] = $child;891 return $this;892 }893 public function notBetween($column, $begin, $end)894 {895 $child = new stdClass();896 $child->type = 'notBetween';897 $child->column = $column;898 $child->value = array($begin, $end);899 $this->pointer->childs[] = $child;900 return $this;901 }902 public function build(array $params = array()) : Built903 {904 $built = new Built();905 $params = array_merge(array(906 'quote' => '`'907 ), $params);908 if (count($this->pointer->childs) > 0) {909 $built->setCommand($this->buildBrakets($this->pointer, $built, $params));910 return $built;911 }else{912 return $built;913 }914 }915 private function buildBrakets(stdClass $brackets, Built $built, array $params = array())916 {917 $command = "";918 $params = array();919 $t = null;920 $bl = null;921 foreach ($brackets->childs as $condition) {922 if ($condition->type == "brackets") {923 $command .= "({$this->buildBrakets($condition, $built, $params)}) {$brackets->operator} ";924 continue;925 }926 $type = $condition->type;927 $column = $condition->column;928 $value = $condition->value;929 // Column930 if(931 $column instanceof Select ||932 $column instanceof Expr ||933 $column instanceof Where934 ) {935 $bl = $column->build();936 // $params = array_merge($params, $bl->getParams());937 $built->setParams($bl->getParams());938 $column = sprintf("(%s)", $bl->getCommand());939 } else if(is_string($column)) {940 $t = $this->common->resolveColumn($column);941 if (is_null($t)) {942 trigger_error("I can't resolve column '{$column}'.", E_USER_WARNING);943 continue;944 } else {945 $column = $t;946 }947 if (!is_null($column["table"])) {948 $column = "`{$column["table"]}`.`{$column["column"]}`";949 } else {950 $column = "`{$column["column"]}`";951 }952 } else if(is_null($column) && in_array($type, array(953 "exists",954 "notExists",955 "expr",956 "and",957 "or",958 ))) {959 // Ommit null. It is allowed for these types.960 } else {961 trigger_error(sprintf("Unsupported type of column '%s'.", Functions::type($column)), E_USER_WARNING);962 continue;963 }964 // Value965 if(966 $value instanceof Select ||967 $value instanceof Expr ||968 $value instanceof Where969 ) {970 $bl = $value->build();971 $built->setParams($bl->getParams());972 $value = sprintf("(%s)", $bl->getCommand());973 } else if(is_string($value) && in_array($type, array("expr"))) {974 // Put where directly.975 } else if(is_string($value) && in_array($type, array("startWith", "notStartWith"))) {976 $built->setParam($t = $this->getUid(), "{$value}%");977 $value = ":{$t}";978 } else if(is_string($value) && in_array($type, array("endWith", "notEndWith"))) {979 $built->setParam($t = $this->getUid(), "%{$value}");980 $value = ":{$t}";981 } else if(is_string($value) && in_array($type, array("contains", "notContains"))) {982 $built->setParam($t = $this->getUid(), "%{$value}%");983 $value = ":{$t}";984 } else if(is_string($value)) {985 $built->setParam($t = $this->getUid(), $value);986 $value = ":{$t}";987 } else if(is_numeric($value)) {988 // Omit numeric989 } else if(is_array($value) && in_array($type, array("in", "notIn"))) {990 $string = "";991 if (empty($value)) {992 if ($type == "in") {993 $value = "1=2";994 } else {995 $value = "1=1";996 }997 } else {998 foreach ($value as $v) {999 if (is_numeric($v)) {1000 $string .= "{$v},";1001 } else {1002 $built->setParam($t = $this->getUid(), $v);1003 $string .= ":{$t},";1004 }1005 }1006 $value = substr($string, 0, strlen($string) - 1);1007 }1008 } else if(is_array($value) && in_array($type, array("between", "notBetween"))) {1009 $begin = $value[0];1010 $end = $value[1];1011 if (!is_numeric($value[0])) {1012 $built->setParam($t = $this->getUid(), $value[0]);1013 $value[0] = ":{$t}";1014 }1015 if (!is_numeric($value[1])) {1016 $built->setParam($t = $this->getUid(), $value[1]);1017 $value[1] = ":{$t}";1018 }1019 } else if(is_array($value) && in_array($type, array("and", "or"))) {1020 // ...1021 $string = "";1022 $operator = $type == "and" ? "AND" : "OR";1023 foreach ($value as $v) {1024 if(1025 $v instanceof Select ||1026 $v instanceof Expr ||1027 $v instanceof Where1028 ) {1029 $bl = $v->build();1030 $built->setParams($bl->getParams());1031 $string .= sprintf("(%s) {$operator} ", $bl->getCommand());1032 } else if(is_string($v)) {1033 $string .= sprintf("(%s) {$operator} ", $v);1034 } else {1035 trigger_error(sprintf("Unssuported type of value for or/and method '%s'.", Functions::type($v)), E_USER_WARNING);1036 }1037 // $where->or(array($a, $b, $c));1038 // (... and (($a) or ($b) or ($c)))1039 }1040 $value = sprintf("(%s)", substr($string, 0, strlen($string) - strlen($operator) - 2));1041 } else if(is_null($value) && in_array($type, array(1042 "isNull",1043 "isNotNull",1044 ))) {1045 // Ommit null. It is allowed for these types.1046 } else {1047 trigger_error(sprintf("Unsupported type of value '%s'.", Functions::type($value)), E_USER_WARNING);1048 continue;1049 }1050 switch ($type) {1051 // ---------------------1052 case "or":1053 case "and":1054 $command .= "{$value}";1055 break;1056 // ---------------------1057 case "expr":1058 $command .= "{$value}";1059 break;1060 // ---------------------1061 case "in":1062 $command .= "{$column} IN({$value})";1063 break;1064 case "notIn":1065 $command .= "{$column} NOT IN({$value})";1066 break;1067 // ---------------------1068 case "isNull":1069 $command .= "{$column} IS NULL";1070 break;1071 case "isNotNull":1072 $command .= "{$column} IS NOT NULL";1073 break;1074 // ---------------------1075 case "like":1076 case "startWith":1077 case "endWith":1078 case "contains":1079 $command .= "{$column} LIKE {$value}";1080 break;1081 case "notLike":1082 case "notStartWith":1083 case "notEndWith":1084 case "notContains":1085 $command .= "{$column} NOT like {$value}";1086 break;1087 // ---------------------1088 case "equal":1089 $command .= "{$column} = {$value}";1090 break;1091 case "notEqual":1092 $command .= "{$column} != {$value}";1093 break;1094 // ---------------------1095 case "lowerThan":1096 $command .= "{$column} < {$value}";1097 break;1098 case "notLowerThan":...

Full Screen

Full Screen

grpconcat_jobassignment.php

Source:grpconcat_jobassignment.php Github

copy

Full Screen

1<?php2/*3 * This file is part of shezar LMS4 *5 * Copyright (C) 2010 onwards shezar Learning Solutions LTD6 *7 * This program is free software; you can redistribute it and/or modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation; either version 3 of the License, or10 * (at your option) any later version.11 *12 * This program is distributed in the hope that it will be useful,13 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with this program. If not, see <http://www.gnu.org/licenses/>.19 *20 * @author Simon Coggins <simon.coggins@shezarlms.com>21 * @package shezar22 * @subpackage reportbuilder23 */24global $CFG;25require_once($CFG->dirroot . '/shezar/reportbuilder/filters/hierarchy_multi.php');26/**27 * Generic filter based on selecting multiple items from a hierarchy.28 */29class rb_filter_grpconcat_jobassignment extends rb_filter_hierarchy_multi {30 const JOB_OPERATOR_ANY = 0;31 const JOB_OPERATOR_CONTAINS = 1;32 const JOB_OPERATOR_NOTCONTAINS = 2;33 const JOB_OPERATOR_EQUALS = 3;34 const JOB_OPERATOR_NOTEQUALS = 4;35 private $jobfield, $jobjoin, $shortname, $showchildren;36 /**37 * Constructor38 *39 * @param string $type The filter type (from the db or embedded source)40 * @param string $value The filter value (from the db or embedded source)41 * @param integer $advanced If the filter should be shown by default (0) or only42 * when advanced options are shown (1)43 * @param integer $region Which region this filter appears in.44 * @param reportbuilder object $report The report this filter is for45 *46 * @return rb_filter_jobassignment_multi object47 */48 public function __construct($type, $value, $advanced, $region, $report) {49 // We don't want to call parent construct because of the extra checks, so directly call the base filter.50 rb_filter_type::__construct($type, $value, $advanced, $region, $report);51 // The field in the job_assignment table that this filter refers to.52 if (!isset($this->options['jobfield']) || !isset($this->options['jobjoin'])) {53 throw new ReportBuilderException('Job assignment filters must have a \'jobfield\' set that maps54 to a field in the job_assignment table. And a \'jobjoin\' which defines the table with more55 information on the associated object');56 }57 $this->jobfield = $this->options['jobfield'];58 $this->jobjoin = $this->options['jobjoin'];59 switch($this->jobfield) {60 case 'positionid':61 $this->shortname = 'pos';62 $this->showchildren = true;63 break;64 case 'organisationid':65 $this->shortname = 'org';66 $this->showchildren = true;67 break;68 case 'managerjaid':69 $this->shortname = 'man';70 $this->showchildren = false;71 break;72 case 'appraiserid':73 $this->shortname = 'app';74 $this->showchildren = false;75 break;76 default:77 throw new ReportBuilderException("Jobfield:'{$this->jobfield}' has not been implemented.");78 break;79 }80 }81 /**82 * Returns an array of comparison operators83 * @return array of comparison operators84 */85 function get_operators() {86 return array(87 self::JOB_OPERATOR_ANY => get_string('isanyvalue', 'filters'),88 self::JOB_OPERATOR_CONTAINS => get_string('filtercontains', 'shezar_reportbuilder'),89 self::JOB_OPERATOR_NOTCONTAINS => get_string('filtercontainsnot', 'shezar_reportbuilder'),90 self::JOB_OPERATOR_EQUALS => get_string('filterequals', 'shezar_reportbuilder'),91 self::JOB_OPERATOR_NOTEQUALS => get_string('filterequalsnot', 'shezar_reportbuilder')92 );93 }94 /**95 * Adds controls specific to this filter in the form.96 * @param object $mform a MoodleForm object to setup97 */98 function setupForm(&$mform) {99 global $SESSION;100 $label = format_string($this->label);101 $advanced = $this->advanced;102 // Container for currently selected items.103 $objs = array();104 $objs['operator'] = $mform->createElement('select', $this->name.'_op', null, $this->get_operators());105 $objs['operator']->setLabel(get_string('limiterfor', 'filters', $label));106 $content = html_writer::tag('div', '', array('class' => 'list-' . $this->name));107 $content .= display_choose_items_link($this->name, $this->shortname);108 $objs['static'] = $mform->createElement('static', $this->name . '_list', null, $content);109 // Only show the children checkbox for hierarchies.110 if ($this->showchildren) {111 $objs['child'] =& $mform->createElement('checkbox', $this->name.'_child', null, get_string('jobassign_children', 'shezar_reportbuilder'));112 }113 $grp =& $mform->addElement('group', $this->name . '_grp', $label, $objs, '', false);114 $mform->addHelpButton($grp->_name, 'reportbuilderjobassignmentfilter', 'shezar_reportbuilder');115 $mform->disabledIf($this->name . '_child', $this->name . '_op', 'eq', 0);116 if ($advanced) {117 $mform->setAdvanced($this->name.'_grp');118 }119 $mform->addElement('hidden', $this->name);120 $mform->setType($this->name, PARAM_SEQUENCE);121 $mform->setType($this->name . '_op', PARAM_INT);122 // set default values123 if (isset($SESSION->reportbuilder[$this->report->get_uniqueid()][$this->name])) {124 $defaults = $SESSION->reportbuilder[$this->report->get_uniqueid()][$this->name];125 }126 if (isset($defaults['value'])) {127 $mform->setDefault($this->name, $defaults['value']);128 }129 }130 function definition_after_data(&$mform) {131 global $DB;132 $group = $mform->getElementValue($this->name . '_grp');133 $operator = !empty($group[$this->name . '_op']) ? $group[$this->name . '_op'] : 0;134 $children = !empty($group[$this->name . '_child']) ? $group[$this->name . '_child'] : 0;135 // Don't set anything if the operator is set to any.136 if (empty($operator[0])) {137 return true;138 }139 if ($ids = $mform->getElementValue($this->name)) {140 list($insql, $inparams) = $DB->get_in_or_equal(explode(',', $ids));141 $items = $DB->get_records_select($this->jobjoin, "id {$insql}", $inparams);142 if (!empty($items)) {143 $list = html_writer::start_tag('div', array('class' => 'list-' . $this->name ));144 foreach ($items as $item) {145 $list .= display_selected_item($this->shortname, $item, $this->name);146 }147 $list .= html_writer::end_tag('div');148 // link to add items149 $list .= display_choose_hierarchy_items_link($this->name, $this->shortname);150 $mform->setDefault($this->name.'_list', $list);151 }152 }153 $values = array();154 $values[$this->name . '_op'] = $operator;155 $values[$this->name . '_child'] = $children;156 $grpel =& $mform->getElement($this->name . '_grp');157 $grpel->setValue($values);158 }159 /**160 * Retrieves data from the form data161 * @param object $formdata data submited with the form162 * @return mixed array filter data or false when filter not set163 */164 function check_data($formdata) {165 $field = $this->name;166 $operator = $field . '_op';167 $children = $field . '_child';168 if (isset($formdata->$field) && !empty($formdata->$field)) {169 return array(170 'operator' => $formdata->$operator,171 'value' => $formdata->$field,172 'children' => isset($formdata->$children) ? $formdata->$children : 0173 );174 }175 return false;176 }177 /**178 * Returns the condition to be used with SQL where179 *180 * @param array $data filter settings181 * @return array containing filtering condition SQL clause and params182 */183 function get_sql_filter($data) {184 global $DB;185 $items = explode(',', $data['value']);186 $operator = $data['operator'];187 $children = $data['children'];188 $query = $this->get_field();189 $field = $this->options['jobfield'];190 $usertab = $this->joins;191 $unique = rb_unique_param('uja'.$this->shortname);192 // don't filter if none selected193 if (empty($items) || $operator == 0) {194 // return 1=1 instead of TRUE for MSSQL support195 return array(' (1 = 1) ', array());196 }197 // Include child hierarchies if the198 if ($children && in_array($this->shortname, array('pos', 'org'))) {199 $childitems = array();200 $childsql = "SELECT id FROM {{$this->shortname}} WHERE (1=0)";201 foreach ($items as $item) {202 $childsql .= ' OR path LIKE \'%/' . $item . '/%\'';203 }204 $items = array_merge($items, $DB->get_fieldset_sql($childsql, array()));205 }206 if ($operator == self::JOB_OPERATOR_CONTAINS || $operator == self::JOB_OPERATOR_NOTCONTAINS) {207 $not = ($operator == self::JOB_OPERATOR_NOTCONTAINS) ? 'NOT ' : '';208 list($insql, $params) = $DB->get_in_or_equal($items, SQL_PARAMS_NAMED, $unique);209 $subtable = $unique . 'tab';210 // Build the sql statement from the filter options.211 if (!empty($this->options['extjoin']) && !empty($this->options['extfield'])) {212 // Allow for one layer of abstraction for managerjaid etc.213 $exttable = $unique . 'ext';214 $extjoin = $this->options['extjoin'];215 $extfield = $this->options['extfield'];216 $fromsql = " FROM {job_assignment} {$subtable} " .217 " INNER JOIN {{$extjoin}} {$exttable} " .218 " ON {$subtable}.{$field} = {$exttable}.id " .219 " WHERE {$subtable}.userid = {$usertab}.id " .220 " AND {$exttable}.{$extfield} {$insql}";221 } else {222 $fromsql = " FROM {job_assignment} {$subtable} " .223 " WHERE {$subtable}.userid = {$usertab}.id " .224 " AND {$subtable}.{$field} {$insql}";225 }226 $query = " {$not}EXISTS (SELECT 1 " . $fromsql . ")";227 } else if ($operator == self::JOB_OPERATOR_EQUALS || $operator == self::JOB_OPERATOR_NOTEQUALS) {228 $not = ($operator == self::JOB_OPERATOR_NOTEQUALS) ? 'NOT ' : '';229 $subquery = array();230 foreach ($items as $item) {231 $unique = rb_unique_param('uja'.$this->shortname);232 $subtable = $unique . 'tab' . $item;233 // Build the sql statement from the filter options.234 if (!empty($this->options['extjoin']) && !empty($this->options['extfield'])) {235 $extjoin = $this->options['extjoin'];236 $extfield = $this->options['extfield'];237 $exttable = $unique . 'ext' . $item;238 // Allow for one layer of abstraction for managerjaid etc.239 $fromsql = " FROM {job_assignment} {$subtable} " .240 " INNER JOIN {{$extjoin}} {$exttable} " .241 " ON {$subtable}.{$field} = {$exttable}.id " .242 " WHERE {$subtable}.userid = {$usertab}.id " .243 " AND {$exttable}.{$extfield} = :{$unique}";244 } else {245 $fromsql = " FROM {job_assignment} {$subtable} " .246 " WHERE {$subtable}.userid = {$usertab}.id " .247 " AND {$subtable}.{$field} = :{$unique} ";248 }249 $subquery[] = " {$not}EXISTS (SELECT 1 " . $fromsql . ")";250 $params[$unique] = $item;251 }252 $query = implode(' AND ', $subquery);253 }254 return array($query, $params);255 }256 /**257 * Include Js for this filter258 *259 */260 public function include_js() {261 global $PAGE;262 $code = array();263 $code[] = shezar_JS_DIALOG;264 $code[] = shezar_JS_TREEVIEW;265 local_js($code);266 $jsdetails = new stdClass();267 $jsdetails->strings = array(268 'shezar_job' => array('choosemanager'),269 'shezar_hierarchy' => array('chooseposition', 'selected', 'chooseorganisation', 'currentlyselected', 'selectcompetency'),270 'shezar_reportbuilder' => array('chooseorgplural', 'chooseposplural', 'choosecompplural')271 );272 $jsdetails->args = array('filter_to_load' => 'jobassign_multi', null, null, null, 'reportid' => $this->report->_id);273 foreach ($jsdetails->strings as $scomponent => $sstrings) {274 $PAGE->requires->strings_for_js($sstrings, $scomponent);275 }276 $PAGE->requires->js_call_amd('shezar_reportbuilder/filter_dialogs', 'init', $jsdetails->args);277 }278}279function display_choose_items_link($name, $type) {280 switch ($type) {281 case 'pos':282 case 'org':283 return display_choose_hierarchy_items_link($name, $type);284 case 'man':285 case 'app':286 case 'user':287 return display_choose_user_items_link($name, $type);288 default:289 return '';290 }291}292function display_selected_item($type, $item, $filtername) {293 switch ($type) {294 case 'pos':295 case 'org':296 return display_selected_hierarchy_item($item, $filtername);297 case 'man':298 case 'app':299 case 'user':300 return display_selected_user_item($item, $filtername);301 default:302 return '';303 }304}305function display_choose_user_items_link($filtername, $type) {306 return html_writer::tag('div', html_writer::link('#', get_string("choose{$type}plural", 'shezar_reportbuilder'),307 array('id' => "show-{$filtername}-dialog")),308 array('class' => "rb-{$type}-add-link"));309}310function display_selected_user_item($item, $filtername) {311 global $OUTPUT;312 $deletestr = get_string('delete');313 $out = html_writer::start_tag('div', array('data-filtername' => $filtername,314 'data-id' => $item->id, 'class' => 'multiselect-selected-item'));315 $out .= fullname($item);316 $deleteicon = $OUTPUT->flex_icon('times-danger');317 $out .= html_writer::link('#', $deleteicon);318 $out .= html_writer::end_tag('div');319 return $out;320}...

Full Screen

Full Screen

pmlif.php

Source:pmlif.php Github

copy

Full Screen

1<?php2namespace core\element\statement;3use core\Element;4use core\system\data;5class pmlif extends Element {6 public $isset;7 public $isnull;8 public $empty;9 public $dataexists;10 public $notempty;11 public $operator;12 public $value;13 public $equalto;14 public $notequalto;15 public $statement;16 public $fileexists;17 public $fileexist;18 public $filedontexist;19 public $morethan;20 public $greaterthan;21 public $ie;22 public $typeof;23 public $contains;24 public $notcontains;25 public $result = false;26 public $route;27 public function __construct() {28 $this->element = __class__;29 parent::__construct(__class__);30 }31 public function render() {32 if (isset($this->dataexists)) {33 $this->result = (bool)data::exist($this->dataexists);34 $this->result = true;35 }36 if (isset($this->isset)) {37 $this->result = true;38 }39 40 if (isset($this->isnull)) {41 if ($this->isnull == null) {42 $this->result = true;43 }44 }45 46 if (isset($this->empty) && empty($this->empty)) {47 $this->result = true;48 }49 if (isset($this->notempty) && !empty($this->notempty)) {50 $this->result = true;51 }52 if (isset($this->equalto)) {53 if ($this->value == $this->equalto) {54 $this->result = true;55 }56 }57 if (isset($this->notequalto)) {58 if ($this->value != $this->notequalto) {59 $this->result = true;60 }61 }62 if (isset($this->statement) && eval("return $this->statement;")) {63 $this->result = true;64 }65 if (isset($this->fileexist) || isset($this->fileexists)) {66 if (isset($this->fileexist)) {67 $file = $this->fileexists = $this->fileexist;68 }69 if (file_exists(env('project.path').$this->fileexists) && !is_dir(env('project.path').$this->fileexists)) {70 $this->result = true;71 }72 }73 if (isset($this->morethan) || isset($this->greaterthan)) {74 if (isset($this->morethan)) {75 $this->greaterthan = $this->morethan;76 }77 if ($this->value > $this->greaterthan) {78 $this->result = true;79 }80 }81 if (isset($this->filedontexist)) {82 if (!file_exists(env('project.path').$this->filedontexist) || is_dir(env('project.path').$this->filedontexist)) {83 $this->result = true;84 }85 }86 if (isset($this->ie)) {87 if (preg_match('/MSIE\s(?P<v>\d+)/i', @$_SERVER['HTTP_USER_AGENT'], $B) && $B['v'] <= $this->ie) {88 $this->result = true;89 }90 }91 if (isset($this->equalto)) {92 if ($this->value == $this->equalto) {93 $this->result = true;94 }95 }96 if (isset($this->contains)) {97 if (strpos($this->value,$this->contains) !== false) {98 $this->result = true;99 }100 }101 if (isset($this->notcontains)) {102 if (strpos($this->value,$this->notcontains) === false) {103 $this->result = true;104 }105 }106 107 if (isset($this->route)) {108 if ($this->route == data::get('app.request.options.route')) {109 $this->result = true;110 }111 }112 /* Possible Types:113 * 'boolean','integer','double','string' */114 if (isset($this->typeof)) {115 $type = null;116 if (is_numeric($this->typeof)) {117 $type = 'integer';118 //if ($type == $this->equalto) {119 // $this->result = true;120 //}121 }122 if(is_bool($this->typeof)) {123 $type = 'boolean';124 //if ($type == $this->equalto) {125 // $this->result = true;126 //}127 }128 if(is_float($this->typeof)) {129 $type = 'double';130 //if ($type == $this->equalto) {131 // $this->result = true;132 //}133 }134 if ($type == null) {135 $type = 'string';136 }137 if ($type == $this->equalto) {138 $this->result = true;139 }140 }141 if ($this->result) {142 return $this->child;143 }144 return false;145 }146}...

Full Screen

Full Screen

notContains

Using AI Code Generation

copy

Full Screen

1{2 public function notContains($str)3 {4 if (strpos($str, 'not') === false) {5 return true;6 } else {7 return false;8 }9 }10}11{12}13$obj = new B();14{15 public function notContains($str)16 {17 if (strpos($str, 'not') === false) {18 return true;19 } else {20 return false;21 }22 }23}24{25}26$obj = new B();27{28 public function notContains($str)29 {30 if (strpos($str, 'not') === false) {31 return true;32 } else {33 return false;34 }35 }36}37{38 public function notContains($str)39 {40 if (strpos($str, 'not') === false) {41 return true;42 } else {43 return false;44 }45 }46}47$obj = new B();48{49 public function notContains($str)50 {51 if (strpos($str, 'not') === false) {52 return true;53 } else {54 return false;55 }56 }57}58{59 public function notContains($str)60 {61 if (strpos($str, 'not') === false) {62 return true;63 } else {64 return false;65 }66 }67}68$obj = new B();

Full Screen

Full Screen

notContains

Using AI Code Generation

copy

Full Screen

1$this->assertNotContains('foo', 'bar');2parent::assertNotContains('foo', 'bar');3$this->assertNotContains('foo', 'bar');4parent::assertNotContains('foo', 'bar');5$this->assertNotContains('foo', 'bar');6parent::assertNotContains('foo', 'bar');7$this->assertNotContains('foo', 'bar');8parent::assertNotContains('foo', 'bar');9$this->assertNotContains('foo', 'bar');10parent::assertNotContains('foo', 'bar');11$this->assertNotContains('foo', 'bar');12parent::assertNotContains('foo', 'bar');13$this->assertNotContains('foo', 'bar');14parent::assertNotContains('foo', 'bar');15$this->assertNotContains('foo', 'bar');16parent::assertNotContains('foo', 'bar');17$this->assertNotContains('foo', 'bar');18parent::assertNotContains('foo', 'bar');19$this->assertNotContains('foo', 'bar');20parent::assertNotContains('foo', 'bar');

Full Screen

Full Screen

notContains

Using AI Code Generation

copy

Full Screen

1$object->notContains("Hello World","Hello");2$object->notContains("Hello World","World");3$object->notContains("Hello World","World");4$object->notContains("Hello World","World");5$object->notContains("Hello World","World");6$object->notContains("Hello World","World");7$object->notContains("Hello World","World");8$object->notContains("Hello World","World");9$object->notContains("Hello World","World");10$object->notContains("Hello World","World");11$object->notContains("Hello World","World");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger notContains code on LambdaTest Cloud Grid

Execute automation tests with notContains on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful