You are here

protected function DrupalApacheSolrService::httpBuildQuery in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::httpBuildQuery()
  2. 6.3 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::httpBuildQuery()

Like PHP's built in http_build_query(), but uses rawurlencode() and no [] for repeated params.

2 calls to DrupalApacheSolrService::httpBuildQuery()
DrupalApacheSolrService::search in ./Drupal_Apache_Solr_Service.php
Simple Search interface
DrupalApacheSolrService::_constructUrl in ./Drupal_Apache_Solr_Service.php
Return a valid http URL given this server's host, port and path and a provided servlet name

File

./Drupal_Apache_Solr_Service.php, line 883

Class

DrupalApacheSolrService
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

Code

protected function httpBuildQuery(array $query, $parent = '') {
  $params = array();
  foreach ($query as $key => $value) {
    $key = $parent ? $parent : rawurlencode($key);

    // Recurse into children.
    if (is_array($value)) {
      $params[] = $this
        ->httpBuildQuery($value, $key);
    }
    elseif (!isset($value)) {
      $params[] = $key;
    }
    else {
      $params[] = $key . '=' . rawurlencode($value);
    }
  }
  return implode('&', $params);
}