note 9033 deleted from function.dbmnextkey by danbrown

From: Date: Fri, 28 Nov 2008 22:41:08 +0000
Subject: note 9033 deleted from function.dbmnextkey by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147372@lists.php.net to get a copy of this message
Note Submitter: fred at ontosys dot com ---- dbmnext() seems to lose the thread if the program deletes keys as it walks through all rows. I imagine that something similar happens with inserts. One way around this is to make two passes: one to collect the keys and one to manipulate the rows. For example: <?php $old_keys = array(); for ($key = dbmfirstkey($db); $key; $key = dbmnextkey($db, $key)) { $old_keys[] = $key; } while (list($_, $key) = each($old_keys)) { dbmdelete($db, $key); } ?>

« previous php.notes (#147372) next »