According to db_insert
manual page this function is deprecated and it is better to use Drupal 8 database connection to perform insert.
Deprecated
as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call insert() on it. For example, $injected_database->insert($table, $options);
Now how can I get a database connection and call insert()
method?
\Drupal::database()->insert(...);
? – Clive♦ Dec 19 '15 at 0:03class PetmdController extends ControllerBase
– Mohammad Ali Akbari Dec 19 '15 at 0:22