Database Operations

Zyxware default image4
| 3 min read
In Drupal 8, the usage of database operations such as select, update and delete are slightly changed from Drupal 7. The db_query() is deprecated in Drupal 8. To fetch a field we can use : $query = \Drupal::database()->query('SELECT myfield from my_table where field1 = :value1 AND field2 = :value2', array( ':value1' => $condition1, ':value2' => $condition2, ) ); $data = $query->fetchField(); Now we can checkout the select, update, and delete operations in Drupal 8. For a field selection use,