条件数组中的元素的键 有用的时候
@param $key string|int 键
@param $value mixed  值
@return array [SQL,Prepare,Param]
357289
private function itemWithKey($key, $value): array
    {
        // 条件中的值,必须是数值或字符串
        if (!is_numeric($value) and !is_string($value) and !is_array($value)) {
            trigger_error('条件值必须是字符串或数字:' . json($this->origin) . ':' . json($value), E_USER_ERROR);
        }

        // 转义字符串的值
        if (is_string($value)) {
            $value = trim($value);
        }

        // 如果键是字段名,那么只能是等于条件或IN
        if ($this->isField($key)) {
            // 如果值 不是数组,那就是等于条件
            if (!is_array($value)) {
                $key = $this->markField($key);

                // 确定了三项的内容
                return [$key . "=" . $this->markValue($value), $key . '=?', $value];
            }

            // 值是数组,就只能是IN了
            $key = $key . ' in';
        }

        // 是否是其它操作运算符
        list ($op, $k) = $this->getOperator($key);

        // 不是其它运算符,三项也可确定了
        if (!$op) {
            return [$key . "=" . $this->markValue($value), $key . "=?", $value];
        }

        //键是一个字段
        $key = $this->markField($k);

        // 处理其它运算符的三项
        switch ($op) {
            case 'BETWEEN':
            case 'NOT BETWEEN':
                // 构造 Between的一对值
                $v = $this->markBetween($value);

                // 生成三项
                return [$key . ' ' . $op . ' ' . $this->sqlBetween($v), $key . ' ' . $op . ' ' . $this->prepareBetween(), $v];
            case 'IN':
            case 'NOT IN':
                // 如果 In/Not In 空数组
                if (empty($value)) {
                    if ($op == 'IN') {
                        // 固定为假
                        return ['FALSE', 'FALSE', []];
                    } else {
                        // 固定为真
                        return ['TRUE', 'TRUE', []];
                    }
                }

                // 构造In的值为数组
                $v = $this->markIn($value);

                // 计算三项
                return [$key . ' ' . $op . ' ' . $this->sqlIn($v), $key . ' ' . $op . ' ' . $this->prepareIn($v), $v];
            case 'IS NULL':
            case 'IS NOT NULL':
                return [$key . ' ' . $op . ' ', $key . ' ' . $op . ' ', []];
            default:
                return [$key . ' ' . $op . ' ' . $this->markValue($value), $key . ' ' . $op . ' ? ', $value];
        }
    }
1226835
public static function transferParameter($key, $value, $type): array
    {
        if (!\is_int($key) && !\is_string($key)) {
            throw new DbException('Key must to be int Or string! ');
        }
        $key = self::formatParamsKey($key);

        // 参数值类型转换
        if ($type !== null) {
            $value = self::trasferTypes($type, $value);
        }

        return [$key, $value];
    }
1092701
public static function options($key, $value = null)
    {
        if (!self::_tableExists()) {
            return;
        }

        if ($value) {
            self::$_options[$key] = $value;
        }

        if (array_key_exists($key, self::$_options)) {
            return self::$_options[$key];
        } else {
            return false;
        }
    }
126633
public function pluck($value, $key = null): array
    {
        return $this
            ->collect(...\array_filter([$value, $key]))
            ->pluck($value, $key)
            ->toArray();
    }
253302
private function getResult($key, $value, $mode) {
        if (is_numeric($key) && is_array($value)) return $this->createSql($value, $key);
        return $this->getConditional($key, $value, $mode);
    }
1089407
public static function all(string $key = NULL, ?string $value = NULL): Collection {
        return static::attempt(function () use ($key, $value): Collection {
            $db = DB::instance();
            if ($key === NULL)
                $dat = $db -> selectall(static::table());
            else $dat = $db -> find(static::table(), implode(',', static::columns()), [$key => $value]);
            $objarr = new Collection();
            foreach ($dat as $local_data) {
                $ld = new static(['id' => $local_data['id']], $local_data);
                $objarr[] = $ld;
            }
            return $objarr;
        });
    }
300679
public function set($key, $value = null)
    {
        if (isset($value)) {
            return $this->array[$key] = $value;
        }

        return $this->array[] = $key;
    }
682954
public function getByValue(string $key, $value)
    {
        return array_filter($this->items, function ($val) use ($key, $value) {
            return $val[$this->normalizeKey($key)] === $value;
        });
    }
5362
public function fetchColumns($key = null, $value = null)
    {
        $this->rewind();

        $result = array();

        if ($key instanceof Database\Definition\Column) {
            $key = $key->schemaName;
        }

        if ($value instanceof Database\Definition\Column) {
            $value = $value->schemaName;
        }

        if (null === $key || null === $value) {
            $r = $this->driver->fetchAssoc($this->result);
            $keys = array_keys($r);
            if (null === $key) {
                $key = $keys[0];
            }
            if (null === $value) {
                $value = $keys[1];
            }
            $result [$r[$key]] = $r[$value];
        }

        while ($r = $this->driver->fetchAssoc($this->result)) {
            $result [$r[$key]] = $r[$value];
        }
        return $result;
    }
344561
private function prepareRow($value)
    {
        if (is_array($value) and count($value) === 1) {
            $value = array_shift($value);
        }

        return $value;
    }
357063
protected function castParam($key, $value)
    {
        if (is_null($value) or ! $this->hasCast($key)) {
            return $value;
        }

        switch ($this->getCastType($key)) {
            case 'int':
            case 'integer':
                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                return (float) $value;
            case 'string':
                return (string) $value;
            case 'bool':
            case 'boolean':
                return (bool) $value;
            case 'array':
                return (array) $value;
            case 'collection':
                return collect((array) $value);
            default:
                return $value;
        }
    }
698581
public static function convertToDb($value)
    {
        if (!is_array($value)) {
            return [];
        }

        $elements = [];
        foreach ($value as $translatable) {
            $elements[] = TranslatableType::convertToDb($translatable);
        }

        return $elements;
    }
1083049
public function sqlFetchPairs(string $sql, array $params = [], string $key = '0', string $value = '1'): array
    {
        return $this->connection()->sqlFetchPairs($sql, $params, $key, $value);
    }
487362
private function item($key, string $value): string
    {
        // 整型,表示不用关注 数组的键了.
        if (is_int($key)) {
            list($key, $value) = $this->itemWithoutKey($value);
        }

        // 去多余的空格
        $key = trim($key);
        $value = trim($value);

        // 如果 字段和方向的顺序写反了,翻过来
        if (strtoupper($key) == 'ASC' or strtoupper($key) == 'DESC') {
            list($key, $value) = [$value, $key];
        }

        // 已经确定了字段和方向
        $field = $key;
        $dim = strtoupper($value);

        // 排序中的方向不被允许
        if ($dim != 'ASC' and $dim != 'DESC') {
            trigger_error('排序方向只能使用ASC或DESC:'.$dim,E_USER_ERROR);
        }

        // 构造SQL中排序语法: 空格分隔
        if ($this->isField($field)) {
            $field = $this->markField($field);
        }

        return $field . ' ' . $dim;
    }
1348107
public function query($key, $value = null)
    {
        $query = array();

        parse_str(
            $this->server()->get('QUERY_STRING'),
            $query
        );

        if (is_array($key)) {
            $query = array_merge($query, $key);
        } else {
            $query[$key] = $value;
        }

        $request_uri = $this->uri();

        if (strpos($request_uri, '?') !== false) {
            $request_uri = strstr($request_uri, '?', true);
        }

        return $request_uri . (!empty($query) ? '?' . http_build_query($query) : null);
    }
200383
public static function where(string $key, string $value){

            return function($compare) use ($key, $value){

                return (@$compare[$key] == $value);

            };

        }
598742
protected function parseKey($key, $value) {
		$point = strpos($key, '.');
		
		if ($point === false) {
			if (is_array($value)) {
				return [$key => array_map(['ZExt\Components\Std', 'parseValue'], $value)];
			}
			
			return [$key => Std::parseValue($value)];
		}
		
		$keyCurrent = trim(substr($key, 0, $point));
		$keyRemains = trim(substr($key, $point + 1));

		if (! isset($keyCurrent[0], $keyRemains[0])) {
			throw new InvalidIniKey('Invalid definition of the key "' . $key . '"');
		}

		return [$keyCurrent => $this->parseKey($keyRemains, $value)];
	}