条件语句
@param bool $condition
@param Closure $trueFunc
@param Closure|null $falseFunc
@return $this
423555
public function when($condition, Closure $trueFunc, Closure $falseFunc = null) {
        if ($condition) {
            $trueFunc($this);
            return $this;
        }
        if (!empty($falseFunc)) {
            $falseFunc($this);
        }
        return $this;
    }
848105
public function markErrorIf($condition, $unlessNull=true){
        if($condition && ($this->value !==null || !$unlessNull)){
            list(, $caller) = debug_backtrace(false);
            $this->errors[$this->field] = $caller['function'];
        }
        return $this;
    }
899444
public function whereNested(Closure $callback, $boolean = 'and')
    {
        call_user_func($callback, $query = $this->forNestedWhere());

        return $this->addNestedWhereQuery($query, $boolean);
    }
155303
public function update($f = false)
    {
        $_where      = '';
        $_table_name = $this->_get_table_name();

        $_set_string = ' SET ';
        $tmp         = array();

        if (is_array($this->data)) {
            foreach ($this->data as $k => $v) {
                $tmp[] = $k . '=' . $v;
            }
            $_set_string .= implode(',', $tmp);
        } elseif (is_string($this->data)) {
            $_set_string .= $this->data;
        }

        if ($this->where) {
            $_where = ' WHERE ' . $this->where;
        } elseif ($this->where == '' && $f == false) {
            throw_error('警告：您似乎漏掉了where条件。如果确认不使用where条件，请使用update(true)');
        }

        // 清理使用过的变量
        $this->data  = array();
        $this->where = '';

        $this->sql = 'UPDATE ' . $_table_name . $_set_string . $_where;
        return $this->conn()->query($this->sql);
    }
1265315
protected function bool(string $name, $default = null): Closure
    {
        return function (Table $table) use ($name, $default) {
            $column = $table->addColumn($name, Type::BOOLEAN)->setNotnull(true);
            if ($default !== null && is_bool($default) === true) {
                $column->setDefault($default);
            }
        };
    }
384992
public function addCondition(ConditionAbstract $condition)
    {
        if ($condition instanceof MediaCondition) {
            $this->conditions[] = $condition;
        } else {
            throw new \InvalidArgumentException(
                "Invalid condition instance. Instance of 'MediaCondition' expected."
            );
        }

        return $this;
    }
144469
@SneakyThrows
    public static <T, R> Function<T, R> doIf(final Predicate<Object> condition, final Supplier<R> trueFunction,
                                             final Supplier<R> falseFunction) {
        return t -> {
            try {
                if (condition.test(t)) {
                    return trueFunction.get();
                }
                return falseFunction.get();
            } catch (final Throwable e) {
                LOGGER.warn(e.getMessage(), e);
                return falseFunction.get();
            }
        };
    }
997403
public function rule(\Closure $closure = null)
    {
        if (null !== $closure) {
            $this->rules[] = $closure;

            return $this;
        }

        return $this->rules[] = new ExprBuilder($this->node);
    }
935452
public function addCondition(ConditionAbstract $condition)
    {
        if ($condition instanceof SupportsCondition) {
            $this->conditions[] = $condition;
        } else {
            throw new \InvalidArgumentException(
                "Invalid condition instance. Instance of 'SupportsCondition' expected."
            );
        }

        return $this;
    }
560917
public function whereNested(Closure $callback, $boolean = 'and')
    {
        $query = $this->newQuery();

        $query->from($this->from);

        call_user_func($callback, $query);

        return $this->addNestedWhereQuery($query, $boolean);
    }
401323
public function when($condition, $query, $otherwise = null)
    {
        if ($condition instanceof \Closure) {
            $condition = $condition($this);
        }

        if ($condition) {
            if ($query instanceof \Closure) {
                $query($this, $condition);
            } elseif (is_array($query)) {
                $this->where($query);
            }
        } elseif ($otherwise) {
            if ($otherwise instanceof \Closure) {
                $otherwise($this, $condition);
            } elseif (is_array($otherwise)) {
                $this->where($otherwise);
            }
        }

        return $this;
    }
825324
public function orWhere($field, $condition = false, $operator = '=')
    {
        if (func_num_args() >= 2) {
            $this->where->addOrCondition($field, $condition, $operator);
        } else {
            $this->where->addOrCondition($field);
        }

        return $this;
    }
605015
public function setSearch(bool $search): self
    {
        if (!$this instanceof Attributable) {
            return $this;
        }

        $searchOption = 'data-selectAR--search';
	    $search ? $this->setAttribute($searchOption, true) : $this->removeAttribute($searchOption);

	    if ($this->hasAttribute('data-selectAR')) {
	    	$this->removeAttribute('data-selectAR');
	    }
        
        return $this;
    }
1002477
public function condition($callback = null)
        {
            if ($callback !== null) {
                if (!is_callable($callback)) {
                    throw new InvalidArgumentException(
                        sprintf(
                            "Condition provided is not a valid callback. Given (%s)",
                            gettype($callback)
                        )
                    );
                }

                $this->conditionCallback = $callback;

                return $this;
            }

            return $this->conditionCallback;
        }
298100
public function map(callable $fn) : self
    {
        $validate = $fn instanceof Closure;

        return new static(array_map($fn, $this->a), $validate);
    }
1352370
public function parent($parent = false)
    {
        if ($parent) {
            $this->parents = !is_array($parent) ? [$parent] : $parent;

            if (func_num_args() > 1) {
                $this->parents = func_get_args();
            }
        }

        return $this;
    }
142383
protected function addCondition($column, Closure $value = null, $separator = 'AND'): self
    {
        if (($column instanceof Closure) && $value === null) {
            $this->sql->addHavingGroupCondition($column, $separator);
        } else {
            $expr = $this->expression->init($column, $separator);
            if ($value) {
                $value($expr);
            }
        }
        return $this;
    }