php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23919 DBA_firstkey and nextkey do not work properly
Submitted: 2003-05-31 06:05 UTC Modified: 2003-05-31 07:09 UTC
From: the dot vinculum at gmx dot de Assigned:
Status: Not a bug Package: DBM/DBA related
PHP Version: 4.3.2 OS: Linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: the dot vinculum at gmx dot de
New email:
PHP Version: OS:

 

 [2003-05-31 06:05 UTC] the dot vinculum at gmx dot de
Hello,
I encountered a bug while working with the DBA Databse (well i guess thats a bug).
I saved Guestbook entries in a DBa because of no support of mySQL at my account.
The way it was saved: x.y = Value
x= is the integer of the entry, eg 1,2,3,4...
y= index of entry, usually to save Name, Title and so on, eg. 1.1, 1.2, 1.3,...
Value is just a String.
This is just en example later i created a DBA with ips, so the key string is an IP which means that it is unknow to me.
Because of this lack of knowledge of the key names i thought to use the firstkey and nextkey functions to search the DB.
I tried it at first at my Guestbook DBa = x.y=Value
Here is the ineffective code:

$id= dba_open ("postings.db", "w", "gdbm");
$str.= dba_firstkey($id)." First Key <br>";
for ($i=1;$i<=200;$i++){
if (dba_nextkey($id)==false){ $str.="$i = False<BR>";} else {
$str.= dba_nextkey($id)."<br>";}
}
echo $str;
dba_close($id);

I know it is ineffective i  used the for loop to make sure that it doenst stops too early .
Fact is that this loop began at 6.3, what is completly nonsense, that is eiter the first key, nor the last.
And i realized that this way to list them does not show all entries, even not the first 1.1.
I guess thats a very big bug, because it makes it impossible to work with the DBA properly.

I hope this description helps you to fix this bug.

Samuel

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-31 07:09 UTC] helly@php.net
Reread the manual. Your code has at least two major problems:

1) dba_firstkey/dba_nextkey return either the value or false. That means you must check with "=== false" not "== false".

2) You have an if statement with dba_nextkey and then do another nextkey which means that you are skipping entries here.

And then your code does not make any sense at all since you do net read the values.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC