I would like to connect to the database from a Drupal 7 module. Currently I only have the query I want to run which is:
$query = db_select('z_lists)
->fields('country')
->condition('value', $country, '=')
->execute()
->fetchAssoc();
What I can’t figure out is how to establish a connection to the default database.
Any help?
In Drupal7 there is function called db_query(). you can use that function to run your queries.
You can use below syntex
$result will be stdClass object so you can use it in foreach loop.