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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 - 16 = ?
Subscribe to this entry?

 
 [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: Wed Jan 27 01:01:24 2021 UTC