Changes to get a more reliable insert ID for any table

This commit is contained in:
moodler
2002-12-22 06:33:30 +00:00
parent d26d7ed0c3
commit 1523be781f
+12 -5
View File
@@ -411,12 +411,19 @@ function insert_record($table, $dataobject, $returnid=true) {
}
if ($returnid) {
// Pull it out again to find the id. This is the most cross-platform method.
if ($rs = $db->Execute("SELECT id FROM $CFG->prefix$table WHERE $select")) {
return $rs->fields[0];
} else {
return false;
if ($db->hasInsertID) {
return $db->Insert_ID(); // ADOdb has stored the ID for us
}
// Try to pull the record out again to find the id. This is the most cross-platform method.
if ($rs = $db->Execute("SELECT id FROM $CFG->prefix$table WHERE $select")) {
if ($rs->RecordCount() == 1) {
return $rs->fields[0];
}
}
return false;
} else {
return true;
}