note 127189 added to function.dba-nextkey

From: Date: Wed, 22 Jun 2022 08:41:31 +0000
Subject: note 127189 added to function.dba-nextkey
Groups: php.notes 
Request: Send a blank email to php-notes+get-218607@lists.php.net to get a copy of this message
It should be noted that it is not always safe to iterate through the database while changing it at the same time. For example: <?php $db=dba_open(...); // remove all values shorter than 10 characters for ($key=dba_firstkey($db); $key!==false; $key=dba_nextkey($db)) { $s=dba_fetch($key, $db); if (strlen($s)<10) { dba_delete($key, $db); } } ?> The above example will work fine with db4 handler, but not with gdbm. It is handler specific. ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.139 (proxied: 2a02:770:4000:0:710e:81f0:870a:5c33) ---- Manual Page -- https://php.net/manual/en/function.dba-nextkey.php Edit -- https://main.php.net/note/edit/127189 Del: integrated -- https://main.php.net/note/delete/127189/integrated Del: useless -- https://main.php.net/note/delete/127189/useless Del: bad code -- https://main.php.net/note/delete/127189/bad+code Del: spam -- https://main.php.net/note/delete/127189/spam Del: non-english -- https://main.php.net/note/delete/127189/non-english Del: in docs -- https://main.php.net/note/delete/127189/in+docs Del: other reasons-- https://main.php.net/note/delete/127189 Reject -- https://main.php.net/note/reject/127189 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218607) next »