|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1230 dbmnextkey misbehaves
Submitted: 1999-03-12 16:51 UTC Modified: 1999-03-13 08:31 UTC
From: eric at ipass dot net Assigned:
Status: Closed Package: DBM/DBA related
PHP Version: 3.0.6 OS: Solaris 2.5.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: eric at ipass dot net
New email:
PHP Version: OS:


 [1999-03-12 16:51 UTC] eric at ipass dot net
It appears that dbmnextkey returns the next key in a dbm file since the last call to dbmnextkey.  Successive calls to dbmnextkey() using the same key value will return different values.  Unless i'm not reading the docs right, dbmnextkey() should return the key after the key passed to it.  So:

echo dbmnextkey($dbm_id, "mykey") . "\n";
echo dbmnextkey($dbm_id, "mykey") . "\n";
echo dbmnextkey($dbm_id, "mykey") . "\n";

... should always echo the same value.  And:

  $dbm_id = dbmopen("anydbm", "w");
  $firstkey = dbmfirstkey($dbm_id);
  $key = $firstkey;
  while ($key) {
    echo "$key = " . dbmfetch($dbm_id, $key) . "\n";
    $key = dbmnextkey($dbm_id, $firstkey);

... should be an infinite loop.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1999-03-13 08:31 UTC] sas
The exact behaviour depends on the underlying implementation scheme. You are only guaranteed that

$key = dbmfirstkey($id);
while($key) {
	$nextkey = dbmnextkey($id, $key);
	$key = $nextkey;

will visit all items in the database.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 23:01:27 2024 UTC