Executes a SELECT query and returns an array where the first column is used as keys and the second as values.

@param  string $key   The column to use as keys
@param  string $value The column to use as values
@return array
432836
public function pairs($key, $value)
	{
		$this->select([$key, $value]);

		$query = $this->compiler->select();

		return $this->connection->pairs($query['sql'], $query['params']);
	}
1126653
public function preparedResults($values)
    {
        $preparedValues = [];

        /* @var $col Col */
        /* @var $field Field */
        foreach ($this->select as $pos => $selectColumn) {
            $col = $selectColumn[0];
            $field = $col->getOutputField();
            $val = ArrayHelper::getValue($values, $pos);
            // first use the inbuilt converters
            try {
                $val = Type::getType(
                    $field->dbType($this->connection)
                )->convertToPHPValue($val, $this->connection->getDatabasePlatform());
            } catch (DBALException $exception) {
            }

            // use the field converters if any were provided by the user.
            $converters = $field->getDbConverters($this->connection);

            if ($converters) {
                foreach ($converters as $converter) {
                    $val = call_user_func($converter, $this->connection, $val, $field);
                }
            }
            $preparedValues[] = $val;
        }

        return $preparedValues;
    }
1311926
public function pluck(string $value, $key = null): Collection
    {
        $results = [];

        list($value, $key) = static::explodePluckParameters($value, $key);

        foreach ($this->items as $item) {
            $itemValue = self::dataGet($item, $value);

            if (is_null($key)) {
                $results[] = $itemValue;
            } else {
                $itemKey = self::dataGet($item, $key);
                $results[$itemKey] = $itemValue;
            }
        }

        return new static($results);
    }
609075
public static function keys($value)
    {

        if (is_array($value)) {
            return array_keys($value);
        }

        if (!is_object($value)) {
            return [];
        }

        if (!$value instanceof Traversable) {
            return array_keys(get_object_vars($value));
        }

        return array_keys(iterator_to_array($value, true));

    }
96924
public function appends($value)
    {
        $appends = explode(',', $value);
        $validator = validator([ 'values' => $appends ], [ 'values.*' => 'string' ]);
        $appends = collect($appends)->mapWithKeys(function ($append) {
            return [ $append => DB::raw("NULL as $append") ];
        })->toArray();
        return $this->builder->when(!$validator->fails(), function (Builder $query) use($appends) {
            if (is_null($query->getQuery()->columns)) {
                $query->select([ '*' => $query->qualifyColumn('*') ]);
                $query->addSelect($appends);
            }
        });
    }
164169
public function get($key, $value = null)
    {
        return $this->queryBag->key($key, $value, true);
    }
276456
public function query($key, $value = null)
    {
        if ($value) {
            return $this->replicate(['query' => [$key => $value]]);
        }

        return $this->replicate(['query' => $key]);
    }
778075
public function countByIndex( $key, $value ){
		$conditions	= array( $key => $value );
		return $this->table->count( $conditions );
	}
380772
public function findByKeyAndValue(string $key, $value): MapInterface
    {
        return $this->find(function (MapInterface $item) use ($key, $value): bool {
            return $item->get($key) === $value;
        });
    }
880689
private function item($key, $value): ?array
    {
        // 键不是整数,有用,需要分析
        if (!is_numeric($key)) {
            return $this->itemWithKey(trim($key), $value);
        }

        //键是整数,无用
        return $this->itemWithoutKey($value);
    }
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;
        });
    }
682954
public function getByValue(string $key, $value)
    {
        return array_filter($this->items, function ($val) use ($key, $value) {
            return $val[$this->normalizeKey($key)] === $value;
        });
    }
1308564
public function search($key, $value)
	{
		foreach ($this->rows as $row)
		{
			if ($row->$key == $value)
			{
				return true;
			}
		}

		return false;
	}
398883
protected function _splitQueryValue($value)
    {
        $data = explode('=', $value, 2);
        if (1 === count($data)) {
            $data[] = null;
        }
        return $data;
    }
200383
public static function where(string $key, string $value){

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

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

            };

        }
1105218
public function SelectKeyValue( $Key , $Value ) {

        $Key = new Expression( $Key );
        $Value = new Expression( $Value );

        $items = array();

        foreach ( $this->repository as $item ) {
            $_k = $Key->execute( $item );
            $_v = $Value->execute( $item );
            $items[$_k] = $_v;
        }

        return new Queryable( $items );

    }
1083049
public function sqlFetchPairs(string $sql, array $params = [], string $key = '0', string $value = '1'): array
    {
        return $this->connection()->sqlFetchPairs($sql, $params, $key, $value);
    }