6

I am trying to use PDO's lastInsertId method, but the documentation states that for some rdbms I need a sequence name as an argument. Only being familiar with mysql, I am not quite sure what a sequence name is. Do they mean the name of the column that contains the auto-increment id? Here is the documentation for the method:

http://php.net/manual/en/pdo.lastinsertid.php

Any information on this would be greatly appreciated. Thanks.

dqhendricks
  • 17,461
  • 10
  • 44
  • 80

1 Answers1

4

Instead of having a primary key auto_incrementing (i.e. MySQL), you can create a named sequence like this:

CREATE SEQUENCE a_sequence INCREMENT BY 5 START WITH 30

So you'd have a column with these values: 30, 35, 40... etc. The lastInsertId method should grab the last sequence value.

Karl Andrew
  • 1,533
  • 11
  • 14