Bitrix Site Manager

CDatabase::LastID

int
CDatabase::LastID()

The method LastID returns the ID of the last added record.

Warning
For use with the MySQL version only!

Parameters

No parameters.

See Also

Example



<?
function AddResultAnswer($arFields)
{
    $err_mess = (CForm::err_mess())."<br>Function: AddResultAnswer<br>Line: ";
    global $DB;
    $arInsert = $DB->PrepareInsert("b_form_result_answer", $arFields, "form");
    $strSql = "INSERT INTO b_form_result_answer (".$arInsert[0].") VALUES (".$arInsert[1].")";
    $DB->Query($strSql, false, $err_mess.__LINE__);
    return intval($DB->LastID());
}
?>