0

I would need to emulate a sequence on MySql.

As explained in this answer Emulating a transaction-safe SEQUENCE in MySQL

I need to run two queries in the same session.

UPDATE sequence SET seq_current = (@next := seq_current + 1) WHERE seq_name = 'foo';
SELECT @next;

How can I do it with Eloquent?

andrean
  • 107
  • 12
  • You can only run these as raw sql queries and will essentially be outside of any object model. – Shadow Oct 04 '22 at 06:27
  • Do not use this method - it is not safe in concurrent environ. Use trigger technique with additional table. PS. XY-problem. You must post the task, not your attempt to solve it only. – Akina Oct 04 '22 at 06:52

0 Answers0