Last active
December 17, 2015 03:49
-
-
Save scarpent/5546366 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNextSequenceNumber($sequenceName) | |
{ | |
global $wpdb; | |
$wpdb->query($wpdb->prepare( | |
" | |
INSERT INTO table_name | |
(seq_name, seq_num) | |
VALUES (%s, LAST_INSERT_ID(1)) | |
ON DUPLICATE KEY UPDATE seq_num = LAST_INSERT_ID(seq_num + 1); | |
", | |
$seq_name | |
)); | |
return $wpdb->get_var("SELECT LAST_INSERT_ID();"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment