Skip to content

Instantly share code, notes, and snippets.

@suresh-kumara-gist
Created October 17, 2017 09:38
Show Gist options
  • Save suresh-kumara-gist/3c16eab505a9e6e33eeee68a5497f3dd to your computer and use it in GitHub Desktop.
Save suresh-kumara-gist/3c16eab505a9e6e33eeee68a5497f3dd to your computer and use it in GitHub Desktop.
drupal 8 address field fetch city
change node__field_location to your address field table name , column name also
$query = \Drupal::database()->select('node__field_location', 'fa');
$query->fields('fa', ['field_location_locality']);
$query->condition('bundle', 'venture');
// $query->condition('field_location_locality', '', 'like');
// $query->condition('field_location_country_code', '');
$query->distinct();
$query->orderBy('field_location_locality');
$courseRatings = $query->execute()->fetchAll(\PDO::FETCH_ASSOC);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment