I am trying to write queries in drupal 8 , I know that I must use the delete() function , however just for testing on my draft I tried the following query and it worked :
$connection = \Drupal::database();
$sql = "DELETE FROM role_expire WHERE uid = :uid AND rid = :rid ";
$query_ = $connection->query($sql, array(":uid" => $drupal_user_id ,":rid" => $role_id));
My question is should I ADD a execute() at the end like then following example that I found while searching and if yes, then how did my query manage to work without it ? :
$database = \Drupal::database();
$query = $database->query("DELETE FROM table WHERE name='jane' AND nickmane='" . $nickname . "'");
$query->execute();
same question for the INSERT query.