Grab the next status id when inserting

merge-requests/2/head
Mike Koch 9 years ago
parent d22c1db84d
commit f2b8fb8f74

@ -644,8 +644,13 @@ function createStatus() {
$row = hesk_dbFetchRow($res);
$my_order = $row[0]+10;
$insert = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` (`Key`, `TextColor`, `IsClosed`, `Closable`, `sort`)
VALUES ('STORED IN XREF TABLE', '".hesk_dbEscape($textColor)."', ".intval($isClosed).", '".hesk_dbEscape($closable)."', ".intval($my_order).")";
// Get the next status id
$res = hesk_dbQuery("SELECT `Id` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` ORDER BY `Id` DESC LIMIT 1");
$row = hesk_dbFetchAssoc($res);
$nextId = $row['Id'] + 1;
$insert = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` (`Id`, `Key`, `TextColor`, `IsClosed`, `Closable`, `sort`)
VALUES (".intval($nextId).", 'STORED IN XREF TABLE', '".hesk_dbEscape($textColor)."', ".intval($isClosed).", '".hesk_dbEscape($closable)."', ".intval($my_order).")";
hesk_dbQuery($insert);
$newStatusId = hesk_dbInsertID();

Loading…
Cancel
Save