php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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-2021 The PHP Group
All rights reserved.
Last updated: Sun Jun 20 10:01:23 2021 UTC