These are some interesting comments from script developer Wayne Stewart regarding re-using id numbers:
[QUOTE=Wayne Stewart]Good question Steven!
After reading your question something nagged at the back of my mind because I had a similar question when I was writing the script. To avoid re-using id numbers I used this code:
Code:
// Create new starting "id" number for mos_users table by
// getting the current highest id number and adding 1
$current_id = mysql_query('SELECT MAX(id) FROM mos_users');
while ($row = mysql_fetch_array($current_id)) {
$old_id = $row[0];
$new_id = $old_id + 1;
print ("<p>Current highest 'id' in mos_users is: " . $row[0]);
print ("<br>The new 'id' numbers will start at: " . $new_id) . "<br>";
}
However you're quite right about what might happen if you delete users THEN use this script. That's much sloppier database programming than I've come to expect from the Mambo development team. After all, maintaining "referential integrity" is a cornerstone of proper database application design. Orphans shouldn't happen, period.
There is a way around this though. Just get the id value from the table that ISN'T updated when you delete a user, like the mos_core_acl_aro table for example.
So the code above becomes:
Code:
// Create new starting "id" number for mos_users table by
// getting the current highest id number and adding 1
$current_id = mysql_query('SELECT MAX(aro_id) FROM mos_core_acl_aro');
while ($row = mysql_fetch_array($current_id)) {
$old_id = $row[0];
$new_id = $old_id + 1;
print ("<p>Current highest 'id' in mos_users is: " . $row[0]);
print ("<br>The new 'id' numbers will start at: " . $new_id) . "<br>";
}
It's unfortunate that it's necessary, but it would work.
As for the orphans, I don't know what harm would be done by deleting them. I suspect that they aren't used for anything once their respective user record is deleted but you would need to check with a member of the dev team to be certain.
Thanks for pointing this out Steven!
Wayne
[QUOTE=candoit]Hello all,
When a new user is created, a record is created in the database for that user in 3 different tables. When the User is deleted by an Administrator in the Backend, the user record (also known as a "row") in the database is only removed from the mos_users table.
A row for the user remains in the mos_core_acl_aro table and in the mos_core_acl_groups_aro_map table.
At least this is the way it is working in my Mambo v 4.5.2.1
Is this the way it is supposed to be? If it is, what data or actions are associated with the records in these 2 tables that are being maintained for the, now deleted, user?
This is IMPORTANT IN REGARDS TO THIS SCRIPT for mass importing of users. If the admin has deleted users in the User Manager and then tries to use the script, an error occurs because MySQL can't create a new record in mos_core_acl_aro or in mos_core_acl_groups_aro_map because the id# from mos_user has already existed and is used in the field "section_value_value_aro" which must be unique and in "group_id_aro_id_groups_aro_map" which also must be unique. Basically what seems to be happening is that MySQL is reusing the ID# of the deleted user but then, since that ID is used in the other tables, can't create the corresponding records in those other tables.
So, any thoughts?
Also, would problems be created by deleting those rows manually? I don't think so since I have done so already.
I assume that, if I create a user and immediately delete the user before they have done anything on the system, I may delete the mos_core_acl_aro and the mos_core_acl_groups_aro_map records for that user with impunity. What about latter? If they are not used for anything after the user is deleted from the mos_users table then they should be removed from the other tables too. I just hate to have orphaned records in my database and as we can see, it can create problems.
Thank you very much for your time.
I really appreciate this forum. I have learned so much from this thread in particular.
Steven[/QUOTE]
[/QUOTE]
_________________
http://gigcalendar.net: the world's first
free solution for maintaining a touring calendar for
Joomla!