Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For the method PDO::lastInsertId(), what do they mean by the argument "sequence name"? (PHP - PDO)

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.

like image 226
dqhendricks Avatar asked Apr 28 '11 18:04

dqhendricks


1 Answers

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.

like image 103
Karl Andrew Avatar answered Oct 22 '22 12:10

Karl Andrew