How to fetch data from the database in Drupal 8?
To retrieve data from a database and print it, use the db_query in the following way in Drupal 8
$result = db_query('SELECT emailFROM {users} WHERE id = %d', 2);
>
while ( $obj = db_fetch_object ($result) ) {
print $obj->email
}
BY Best Interview Question ON 15 Apr 2021