Fetches rows as $key=>$value pairs.
@param string $key Key column
@param string $value Value column. NULL for whole row.
@return Row[]
183342
public function fetchPairs($key, $value = null){
		$clone = clone $this;

		// If executed w/o needed cols, force exec w/ them.
		if(!in_array('*', $clone->columns)){
			if($value !== null)
				$clone->columns = array($key, $value);
			elseif(!in_array($key, $clone->columns))
				$clone->columns[] = $key;
		}
		$k = substr($key, ($pk = strrpos($key, '.')) ? $pk+1 : 0);
		$v = $value === null ? null : substr($value, ($pv = strrpos($value, '.')) ? $pv+1 : 0);

		$rows = array();
		while($row = $clone->fetch()){
			if(!$row)
				return array();
			$rows[$row[$k]] = $value === null ? $row : $row->$v;
		}

		return $rows;
	}
865134
protected static function extractKeyValueParameters($value, $key)
    {
        $value = is_string($value) ? explode('.', $value) : $value;
        $key   = is_null($key) || is_array($key) ? $key : explode('.', $key);

        return [$value, $key];
    }
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)];
	}
906924
public function lists($value = null, $key = null, array $options = []) {
        $repo = $this->getRepository();
        $key = $key ?: $repo->getPrimaryKey();
        $value = $value ?: $repo->getDisplayField();

        $options['key'] = $key;
        $options['value'] = $value;

        return $this->fields([$key, $value], true)->find('list', $options);
    }
774449
public function share($key, $value = null)
    {
        $keys = is_array($key) ? $key : [$key => $value];

        foreach ($keys as $key => $value) {
            $this->shared[$key] = $value;
        }

        return $value;
    }
1129479
private function parseArray(string $key, $value): string
    {
        return sprintf('%s%s%s', $key, $this->delimiter, implode(',', $value));
    }
1319475
protected function getValue( $key, $value = null )
	{
		if( is_null( $value ) && isset( $this->args[$key] )) {
			$value = $this->args[$key];
		}
		return $value;
	}
747872
protected function renderKeyValuePair($key, $value)
    {
        $output = [];
        $value = $this->normalizeValue($value);

        if (is_array($value)) {
            foreach ($value as $v) {
                $output[] = sprintf('%s[] = %s', $key, $v);
            }
        } else {
            $output[] = sprintf('%s = %s', $key, $value);
        }

        return $output;
    }
475597
public function append($value, $key = null): Arrayy
    {
        $this->checkTypeWrapper($value);

        return parent::append($value, $key);
    }
749750
private function fetchValueForKey($key, $value)
    {
        if (in_array($key, $this->getDates())) {
            return trim($value) === '' ? null : $value;
        }

        if (! $this->hasSetMutator($key)) {
            $value = $this->getAttribute($key);
        }

        if ($this->isJsonCastable($key) && ! is_null($value)) {
            $value = is_string($value) ? $this->getJsonCastValue($value) : $value;
        }

        return $value;
    }
123139
public function where($key, $value=null)
    {
        if($value)
            return $this->model->where($key, $value);
        if(is_array($key))
            return $this->model->where($key);
        return null;
    }
457132
private function splitQueryValue(string $value): array
    {
        $data = \explode('=', $value, 2);
        if (!isset($data[1])) {
            $data[] = null;
        }

        return $data;
    }
873103
public function nullIfEmpty($value, $key = null)
    {
        if (! is_null($key)) {
            $value = $this->fetchValueForKey($key, $value);
        }

        if (is_array($value)) {
            return $this->nullIfEmptyArray($key, $value);
        }

        if (is_bool($value)) {
            return $value;
        }

        return trim($value) === '' ? null : $value;
    }
434122
protected static function explodePluckParameters($value, $key)
	{
		$value = is_null($key) || is_array($value) ? $value : static::toKey($value)->segments();
		$key = is_null($key) || is_array($key) ? $key : static::toKey($key)->segments();
		return [$value, $key];
	}
682954
public function getByValue(string $key, $value)
    {
        return array_filter($this->items, function ($val) use ($key, $value) {
            return $val[$this->normalizeKey($key)] === $value;
        });
    }
477144
private function hydrateMapValue($key, $value)
    {
        $row = [];
        $mode = array_key_exists($key, $this->mappings) ? $this->mappings[$key][1] : self::HYDRATE_RAW;

        if ($mode === self::HYDRATE_SINGLE) {
            $row = $this->em->getEntityHydrator($this->mappings[$key][0])->hydrateNode($value);
        } elseif ($mode === self::HYDRATE_COLLECTION) {
            $coll = [];
            foreach ($value as $i) {
                $v = $this->em->getEntityHydrator($this->mappings[$key][0])->hydrateNode($i);
                $coll[] = $v;
            }
            $row = $coll;
        } elseif ($mode === self::HYDRATE_MAP_COLLECTION) {
            $row = $this->hydrateMapCollection($value);
        } elseif ($mode === self::HYDRATE_MAP) {
            $row = $this->hydrateMap($value);
        } elseif ($mode === self::HYDRATE_RAW) {
            $row = $value;
        }
        return $row;
    }
1022838
public function pluck($value, $key = null)
    {
        $this->newQuery();

        $lists = $this->query->pluck($value, $key);

        if (is_array($lists)) {
            return $lists;
        }

        return $lists->all();
    }