getTableColumns($data->table, $typeOnly = false) as $column => $info) { if ($info->Extra === 'auto_increment') { $pk = $column; } } if (!$pk) { // no primary keys with auto increment return; } // fetch highest ID $q = $dbo->getQuery(true)->select('MAX(' . $dbo->qn($pk) . ')')->from($dbo->qn($data->table)); $dbo->setQuery($q); $dbo->execute(); $set_ai = (int) $dbo->loadResult() + 1; $dbo->setQuery("ALTER TABLE `{$data->table}` AUTO_INCREMENT = {$set_ai}"); $dbo->execute(); } }