Known limitations of SELECT ... WHERE ... IN ()? (2 replies)

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
Submitted by programmer on Thu, 08/14/2008 - 17:34.

Below I have some PHP code which is a loop to go through and delete a series of users; however, it seems to fail when $in is too large. I'm trying to figure out what determines too large? Is it a PHP issue of the variable being too long? Is it a MySQL issue of how big $in can be? If I can figure it out what/where the limitation is then I could probably program around it by dumping $in into an array and processing it in chunks. Any suggestions or ideas would be appreciated?

Peace - Anthony Borrow, SJ

--- code segment ---

$in = implode(',', $SESSION->bulk_users);

if ($rs = get_recordset_select('user', "id IN ($in)")) {

while ($user = rs_fetch_next_record($rs)) {

if ($primaryadmin->id != $user->id and $USER->id != $user->id and delete_user($user)) {

unset($SESSION->bulk_users[$user->id]);

} else {

notify(get_string('deletednot', '', fullname($user, true)));

}

}

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.