How To Get Auto Increment Id By Pdo Before Execute
I looking for an solutions on 'How to get auto increment id by PDO before execute', is there a way to get the future ID in pdo. I tried lastinsertID but that can only after the 'e
Solution 1:
You can do INSERT with SELECT MAX():
INSERTINTO table1
(id, column1, column2)
(SELECT (MAX(id)+1), 'value1', 'value2'FROM table1)
and increment ID column with whatever you want value.
Solution 2:
$insert = $dbh->prepare('INSERT INTO _gegevensgebruiker ((SELECT MAX(id)+1), company, name, adress, zipcode, city, tel, email, employees, representative, email_re, function, date_end, user, `date_add`) VALUES (NULL, :company, :name, :adress, :zipcode, :city, :tel, :email, :employees, :representative, :email_re, :function, :date_end, :meid, NOW())');
Post a Comment for "How To Get Auto Increment Id By Pdo Before Execute"