Generic querystring generator for some of the Updates methods.

@param  array  $data
@return string
976007
protected function buildProfileUpdatesPayload($data)
    {
        $payload = array();

        if (isset($data['page']) and is_numeric($data['page'])) {
            $payload['page'] = $data['page'];
        }

        if (isset($data['count']) and is_numeric($data['count'])) {
            $payload['count'] = $data['count'];
        }

        if (isset($data['since']) and is_numeric($data['since'])) {
            $payload['since'] = $data['since'];
        }

        if (isset($data['utc']) and $data['utc']) {
            $payload['utc'] = $data['utc'];
        }

        if (isset($data['event'])) {
            $available = array(
                'retweet', 'retweets', 'favorite', 'favorites', 'like', 'likes', 'comment', 'comments',
                'mention', 'mentions', 'share', 'shares',
            );

            if (in_array($data['event'], $available)) {
                $payload['event'] = $data['event'];
            }
        }

        return (count($payload) > 0) ? http_build_query($payload) : '';
    }
1260209
protected function parseQueryString($data) {
        $params = explode('&', $data);

        foreach ($params as $param) {
            $parts = explode('=', $param, 2);
            $name  = trim(urldecode($parts[0])); if (!strlen($name)) continue;
            //$name  = str_replace(['.', ' '], '_', $name);                             // replace as the PHP implementation does
            $value = sizeof($parts)==1 ? '' : urldecode($parts[1]);

            // TODO: process multi-dimensional arrays

            if (($open=strpos($name, '[')) && ($close=strpos($name, ']')) && strlen($name)==$close+1) {
                // name is an array index
                $name = trim(substr($name, 0, $open));
                $key  = trim(substr($name, $open+1, $close-$open-1));

                if (!strlen($key)) {
                    $_GET[$name][] = $_REQUEST[$name][] = $value;
                }
                else {
                    $_GET[$name][$key]                                    = $value;
                    !isset($_POST[$name][$key]) && $_REQUEST[$name][$key] = $value;   // GET must not over-write POST
                }
            }
            else {
                // name is not an array index
                $_GET[$name]                              = $value;
                !isset($_POST[$name]) && $_REQUEST[$name] = $value;                  // GET must not over-write POST
            }
        }
    }
317438
private function getHeaderPrefix(array $data)
    {
        if ($this->first && $this->csvFormat->hasHeaderRow()) {
            $this->first = false;
            $postHeaderPad = $this->csvFormat->getDataStart() - $this->csvFormat->getHeaderRow();
            return $this->format(array_keys($data)) . str_repeat($this->getRowSeparator(), $postHeaderPad);
        }
        return '';
    }
871509
public function getSuggestionFormat(array $data)
    {
        //if no suggestion format
        if (!isset($this->data['suggestion']) || !trim($this->data['suggestion'])) {
            //use best guess
            $suggestion = null;
            foreach ($data as $key => $value) {
                if (is_numeric($value)
                    || (
                        isset($value[0])
                        && is_numeric($value[0])
                    )
                ) {
                    continue;
                }

                $suggestion = $value;
                break;
            }

            //if still no suggestion
            if (is_null($suggestion)) {
                //just get the first one, i guess.
                foreach ($data as $key => $value) {
                    $suggestion = $value;
                    break;
                }
            }

            return $suggestion;
        }

        $template = cradle('global')->handlebars()->compile($this->data['suggestion']);

        return $template($data);
    }
1110472
public function generate(array $data): string
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
        $staticdataUids = $recordFinder->findUidsOfStaticdata();
        // Return only one element
        return (string)current($staticdataUids);
    }
866785
private function getUrl(array $data)
    {
        $urlParams = ['q' => $data['value'], $data['attribute_code'] => $data['value']];

        return $this->urlBuilder->getUrl('catalogsearch/result', ['_query' => $urlParams]);
    }
728343
static function ArrayToQueryString($arr)
	{
		$qs = $arr;

		if (is_array($arr))
		{
			// convert the data array into a url querystring
			$qs = "";
			$delim = "";
			foreach (array_keys($arr) as $key)
			{
				$qs .= $delim . $key ."=" . $arr[$key];
				$delim = "&";
			}
		}

		return $qs;
	}
311748
public static function fromString($query, array $data = [])
    {
        $url = parse_url($query);
        $query = isset($url['query']) ? $url['query'] : $url['path'];
        parse_str($query, $data);

        return new QueryString($data);
    }
261923
private function asData(array $data)
    {
        foreach ($data as $key => $value) {
            if ($value instanceof RawSqlFragmentInterface) {
                $data[$key] = $value->getFragment();
            } elseif ($value instanceof RawBindingInterface) {
                $data[$key] = $value->getTarget();
            } else {
                $placeholder = $this->getUniqPlaceholder();

                $data[$key] = $placeholder;
                $this->bind($placeholder, $value);
            }
        }

        return $data;
    }
542008
public function getQueryFieldsOnDuplicateUpdate(DataAbstract $data)
    {
        if (!$data->isUpdated()) {
            return '';
        }

        //~ List of fields to update.
        $queryFields = array();

        //~ Check for updated fields.
        foreach ($this->fields as $field) {

            //~ Skip fields that are not updated
            if (!$this->isDataUpdated($data, $field)) {
                continue;
            }

            $queryFields[] = $field . ' = :' . strtolower($field);

            $this->binds[':' . strtolower($field)] = $this->getDataValue($data, $field);
        }

        $onDuplicateUpdate = '';
        if (!empty($queryFields)) {
            $onDuplicateUpdate = 'ON DUPLICATE KEY UPDATE ' . implode(', ', $queryFields);
        };

        return $onDuplicateUpdate;
    }
1053288
public function createRequestUrl(array $data)
    {
        $this->ensureApiIsConfigured();

        $data = $this->createRequestData($data);

        $url = $this->getEndpoint() . '?' .
            implode('&', array_map(function ($key, $value) {
                return $key . '=' . rawurlencode($value);
            }, array_keys($data), $data));

        return $url;
    }
425791
protected function getQueryString(?array $query) : ?string
    {
        if (empty($query)) {
            return null;
        }

        return '?' . http_build_query($query, null, '&', PHP_QUERY_RFC3986);
    }
1015790
private function routeRegexpLocales(array $data = null) : string
    {
        if (!is_null($data)) {
            $dest = self::locale();
        } else {
            $dest = '(?:' . implode('|', self::translator()->getLocales()) . ')';
        }

        return $dest;
    }
520522
public static function toComment(array $data): string
    {
        $result = [];
        foreach ($data as $key => $value) {
            $result[] = $key . ': ' . $value . ';';
        }

        return implode(PHP_EOL, $result);
    }
929862
public function sitesEdit(array $data)
    {
        if (!array_key_exists('code', $data)) {
            throw new \InvalidArgumentException(
                'Data must contain "code" parameter.'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            sprintf('/reference/sites/%s/edit', $data['code']),
            "POST",
            ['site' => json_encode($data)]
        );
    }
1215607
public static function createSelectString(array $data) : string
    {
        if (isset($data[0])) {
            $data = $data[0];
        }

        return implode(',', array_keys($data));
    }
1107865
public function update($data = null)
    {
        $fields = $this->getFields();
        $sql1 = '';
        $args = array();
        foreach ($fields as $field) {
            if (in_array($field, $this->updated_at_fileds)) {
                $this->{$field} = now();
            }
            $value = $this->getFieldValue($field, $data);
            if (isset($value) && !$this->isIndex($field)) {
                $args[] = $value;
                $sql1 .= "`$field` = ?, ";
            }
        }
        if (!empty($sql1)) {
            $sql1 = substr($sql1, 0, -2);
            $index = $this->getIndex();
            $indexValue = $this->db->escape_string($this->getFieldValue($index, $data));
            if (!$indexValue) {
                return false;
            }
            $args[] = $indexValue;
            return $this->db->exec("UPDATE `{$this->table_name}` SET $sql1 WHERE `$index` = ?", $args, $this->getCacheId($indexValue));
        }
        return false;
    }