I'm using MariaDB as database backend and I would like to use built in "Sequences" to get an integer number generator. I need to dinamically create sequences and get their values. Following this documentation I know the right sql commands to do it and I have tested it on MariaDB, but I haven't found a way to run this commands from Drupal 8 database connection object. I can only do selects, updates, inserts or deletes. How could I run this custom sql? I need it because I have to create custom sequences on submit some form.
I haven't found a way to run this commands from Drupal 8 database connection object. I can only do selects, updates, inserts or deletes
That's not true, you can also run arbitrary queries, e.g.:
\Drupal::database()->query('TRUNCATE TABLE foo');
-
Yes, it works. I've tried with "CREATE SEQUENCE..." but I always got an error and I supposed I didn't work. I don't know what I did to get this error. I'm sorry. You are right. It works good. – briast Nov 12 '20 at 16:04
You can run your SQL query in your Drupal Project. Read this Static Queries Article. you will get detailed explaination of syntax and examples.